You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran across this while building c_utilities on gcc 4.9.2:
[ 12%] Building C object CMakeFiles/c_utilities.dir/src/cmdline_parser.c.o
/home/chip/sros2/src/ros2/c_utilities/src/cmdline_parser.c: In function ‘cli_option_exist’:
/home/chip/sros2/src/ros2/c_utilities/src/cmdline_parser.c:22:3: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (size_t i = 0; i < (size_t)(end - begin); ++i) {
^
/home/chip/sros2/src/ros2/c_utilities/src/cmdline_parser.c:22:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
CMakeFiles/c_utilities.dir/build.make:62: recipe for target 'CMakeFiles/c_utilities.dir/src/cmdline_parser.c.o' failed
make[2]: *** [CMakeFiles/c_utilities.dir/src/cmdline_parser.c.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/c_utilities.dir/all' failed
make[1]: *** [CMakeFiles/c_utilities.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
that is a good point, I tried to address this on the compile_options branch but didn't have time to test it or open a PR accordingy.
Although MSVC doesn't support it IIRC so all c code declare loop variable beforehand, very surprised that this passed on windows in the first place o_O. So unless MSVC is now c99 compliant 🎉 , I think that the c code should also be modified to declare size_t i; before the for loop.
Yeah, since MSVC doesn't support C11 I don't think we should try and turn it on. We don't need it really anyways. As @mikaelarguedas said, I think the code should be updated to declare the i outside the loop.
Activity
mikaelarguedas commentedon Apr 2, 2017
that is a good point, I tried to address this on the compile_options branch but didn't have time to test it or open a PR accordingy.
Although MSVC doesn't support it IIRC so all c code declare loop variable beforehand, very surprised that this passed on windows in the first place o_O. So unless MSVC is now c99 compliant 🎉 , I think that the c code should also be modified to declare
size_t i;before the for loop.wjwwood commentedon Apr 2, 2017
Yeah, since MSVC doesn't support C11 I don't think we should try and turn it on. We don't need it really anyways. As @mikaelarguedas said, I think the code should be updated to declare the
ioutside the loop.codebot commentedon Apr 2, 2017
implemented in #8
dirk-thomas commentedon Apr 3, 2017
The code itself (not the tests) should be compiled with all warnings enabled. Currently that is still not the case (only when tests are enabled).
Fix leak in test_logging_macros.cpp
Fix leak in test_logging_macros.cpp (#152)
Fix leak in test_logging.cpp
Fix leak in test_logging.cpp (#153)