argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
377 stars 65 forks source link

`-Wpedantic` should be used conditonally on GCC version #88

Closed barracuda156 closed 10 months ago

barracuda156 commented 10 months ago

The build fails with gcc-4.2 due to this flag:

cc1: error: unrecognized command line option "-Wpedantic"

Once removed, it succeeds.

I.e., it should be added conditionally, not for all GCC.

barracuda156 commented 10 months ago

P. S. There is no reason not to support older gcc, all tests pass with it:

--->  Testing argtable3
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_argtable3/argtable3/work/build" && /usr/bin/make test 
Running tests...
/opt/local/bin/ctest --force-new-ctest-process 
Test project /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_argtable3/argtable3/work/build
    Start 1: test_shared
1/3 Test #1: test_shared ......................   Passed   32.89 sec
    Start 2: test_src
2/3 Test #2: test_src .........................   Passed   33.82 sec
    Start 3: test_amalgamation
3/3 Test #3: test_amalgamation ................   Passed   35.98 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) = 102.70 sec
tomghuang commented 10 months ago

One way to prevent this problem is using the amalgamation version of this library: just include argtable3.c and argtable.h in your project.

barracuda156 commented 10 months ago

Thank you for responding. We have fixed it locally in Macports by conditionally (on compiler version) removing the breaking flag. It may still be beneficial to fix it in the master, IMO, since there may be people who try using it without Macports.

tomghuang commented 10 months ago

@barracuda156 : may I know how you fixed it in CMake?

barracuda156 commented 10 months ago

@tomghuang We just used a conditional patch to remove the flag from CMakeLists, however it can be implemented in CMake with something like:

if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.2)

(I can make a PR if that makes it simpler.)

tomghuang commented 10 months ago

@barracuda156 : yes, the CMake code snippet that you proposed is a better solution. Please submit a PR for this improvement. Thanks.

barracuda156 commented 10 months ago

Perhaps like this: https://github.com/argtable/argtable3/pull/89