Skip to content

Explicitly set C11 via the CMake variable - #26

Closed
esteve wants to merge 3 commits into
ros2:masterfrom
esteve:c99
Closed

esteve wants to merge 3 commits into
ros2:masterfrom
esteve:c99

Conversation

@esteve

@esteve esteve commented Jun 6, 2017

Copy link
Copy Markdown
Member

The version of C standard wasn't explicit, so I added CMAKE_C_STANDARD and set it to 99 (if I'm not mistaken that's the version that ROS2 is targeting).

I also added some logic that enables switching to C11 to enable _Thread_local instead of __thread

@wjwwood wjwwood added the in progress Actively being worked on (Kanban column) label Jun 6, 2017
@mikaelarguedas

Copy link
Copy Markdown
Member

Thanks @esteve, we currently don't use the CMAKE_X_STANDARD but that would be a great improvement and more platform/compiler agnostic way to do in every package rather than passing -std flags everywhere

@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 6, 2017
Comment thread include/rcutils/macros.h
// Some other non-Windows, non-cygwin, non-apple OS
#define RCUTILS_THREAD_LOCAL _Thread_local
#if __STDC_VERSION__ >= 201112L
// C11 enabled

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this comment at the end of the previous line (or indent it to the level of the current block).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread CMakeLists.txt Outdated
endif()

if(NOT WIN32)
add_definitions(-D_POSIX_C_SOURCE=199309L)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for?

@esteve esteve Jun 9, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was needed for clock_gettime, but only if std=c99 was used instead. CMAKE_C_STANDARD already causes CMake to set the appropriate flags so _POSIX_C_SOURCE is not needed

Edit: I removed this define in bf792e5

@esteve

esteve commented Jun 15, 2017

Copy link
Copy Markdown
Member Author

I just rebased this to resolve any potential conflicts, let me know if there's any further work that needs to be done.

@mikaelarguedas

Copy link
Copy Markdown
Member

Thanks @esteve ! I'm trying out the same logic on every package and will run CI with all of them including your branches on rmw and rcl

@esteve

esteve commented Jun 15, 2017

Copy link
Copy Markdown
Member Author

@mikaelarguedas no problem, great idea to use CMAKE_C_STANDARD, CMAKE_CXX_STANDARD and add_compile_options() in all the packages.

@dirk-thomas

Copy link
Copy Markdown
Member

Please see #36 for switching to use C11.

@mikaelarguedas

Copy link
Copy Markdown
Member

@esteve would you mind changing this one to C11 as well ? It proved to generate warnings on OSX because of the new variadic logging macros. thanks!

@esteve

esteve commented Jun 16, 2017

Copy link
Copy Markdown
Member Author

@mikaelarguedas done, I've pushed 4224fa1 to switch to C11

@esteve esteve changed the title Default to C99, but allow switching to C11 Explicitly set C11 via the CMake variable Jun 16, 2017

@mikaelarguedas mikaelarguedas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, @dirk-thomas do you want to push style fixup to this before merging ?

Comment thread include/rcutils/macros.h
#define RCUTILS_THREAD_LOCAL _Thread_local
#else
#define RCUTILS_THREAD_LOCAL __thread
#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need / want to keep this with C11 being selected? I would be in favor or removing the change and keeping it as-is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to remove this given that C11 will be selected by default from now on

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remaining patch is already part of #35. Should we close this than?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that works, when do you expect to land #35 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asap.

@dirk-thomas

Copy link
Copy Markdown
Member

@esteve Thank you for working on this. We well merge #35 soon so I will close this.

@dirk-thomas dirk-thomas added duplicate This issue or pull request already exists and removed in review Waiting for review (Kanban column) labels Jun 16, 2017
@esteve

esteve commented Jun 19, 2017

Copy link
Copy Markdown
Member Author

@dirk-thomas no problem, happy to see this getting merged one way or another :-)

@esteve
esteve deleted the c99 branch June 19, 2017 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants