Consistent Compilation In C
Compiling C program using
-std option will save me from a bunch of problems about portability of my program. I use
C99 standart, since
C11 is not widely implemented yet.
Sometimes I need a function definitions that are not specified in ISO C standart. Such as
freeaddrinfo for socket stuff. Those functions are specified in POSIX.1-2008 standart.
-std=c99 option will force a system headers to only expose a definitions that valid in ISO C99 standarts, and it’s good. Compiling a program that include a system header and use a functions that are not specified in the standart will yield the following errors:
I need to define feature test macros for POSIX.1-2008 explicitly in order to tell compiler that I need a features from POSIX.1-2008 standart:
This macro causes header files to expose definitions corresponding to the POSIX.1-2008 base specification (excluding the XSI extension) when program is compiled.
Now, my program will consistently compiled in POSIX-compliant system.