cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
891 stars 114 forks source link

Compiler warning/error: “_BSD_SOURCE and _SVID_SOURCE are deprecated” #334

Closed Wuzzy2 closed 9 years ago

Wuzzy2 commented 9 years ago

When I try to compile d2060413c9a0b313e76bbe3c6336c998a745ddfe under GNU/Linux, I get a compiler warning which is treated as error:

In file included from /usr/include/assert.h:35:0,
                 from /home/wuzzy/src/cdogs-sdl/git/src/cdogs/utils.h:52,
                 from /home/wuzzy/src/cdogs-sdl/git/src/cdogs/utils.c:50:
/usr/include/features.h:148:3: Fehler: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Werror=cpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^
[ 23%] cc1: Alle Warnungen werden als Fehler behandelt
src/tests/CMakeFiles/autosave_test.dir/build.make:192: recipe for target 'src/tests/CMakeFiles/autosave_test.dir/__/cdogs/utils.c.o' failed
make[2]: *** [src/tests/CMakeFiles/autosave_test.dir/__/cdogs/utils.c.o] Error 1
CMakeFiles/Makefile2:443: recipe for target 'src/tests/CMakeFiles/autosave_test.dir/all' failed
make[1]: *** [src/tests/CMakeFiles/autosave_test.dir/all] Error 2

(“Fehler:” is German for “Error:”. “Alle Warnungen werden als Fehler behandelt” is German for “All warnings are treated as errors”.)

I could fix this by changing line 49 of utils.c from #define _BSD_SOURCE to #define _DEFAULT_SOURCE.

cxong commented 9 years ago

Looks like _DEFAULT_SOURCE was added in glibc 2.19 and _BSD_SOURCE deprecated in version 2.20. Both these versions are quite new so I think we'll need to test for the existence of _DEFAULT_SOURCE before using it.

cxong commented 9 years ago

Correction: I think just adding a #define _DEFAULT_SOURCE in addition should work.