ThrowTheSwitch / Unity

Simple Unit Testing for C
ThrowTheSwitch.org
MIT License
4.02k stars 969 forks source link

Build fails with -Werror=missing-declarations when UNITY_USE_COMMAND_LINE_ARGS is enabled #727

Closed mchernosky closed 5 months ago

mchernosky commented 5 months ago

Run cmake with:

cmake -DCMAKE_C_FLAGS="-DUNITY_USE_COMMAND_LINE_ARGS" -B build -S .

Then build with cmake --build build, and get these errors:

Unity/src/unity.c:2354:5: error: no previous declaration for ‘IsStringInBiggerString’ [-Werror=missing-declarations]
 2354 | int IsStringInBiggerString(const char* longstring, const char* shortstring)
      |     ^~~~~~~~~~~~~~~~~~~~~~
Unity/src/unity.c:2399:5: error: no previous declaration for ‘UnityStringArgumentMatches’ [-Werror=missing-declarations]
 2399 | int UnityStringArgumentMatches(const char* str)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
gmake[2]: *** [CMakeFiles/unity.dir/build.make:76: CMakeFiles/unity.dir/src/unity.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/unity.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

The complier is: GNU 11.4.0

mchernosky commented 5 months ago

I have in incoming PR to fix this by marking these functions as static.