[MPlayer-cvslog] Multiple header inclusions -was: license wars!
Rich Felker
dalias at aerifal.cx
Thu Jan 3 19:31:20 CET 2008
On Thu, Jan 03, 2008 at 02:28:51PM +0200, Ivan Kalvachev wrote:
> One artificial (but possible) example:
>
> #include "config.h"
> #include "mp_msg.h"
> #define _GNU_SOURCE
> #include <stdio.h>
> int main(){
> return (int)asprintf("Hello World\n");
> }
>
> If for some reason "mp_msg.h" includes <stdio.h> , it would define the
> standard posix capabilities and would enable its own multiple
> inclusion guard. After that the definition of _GNU_SOURCE would not
> have any effect as the guard would prevent redefinition. The asprintf
> function would remain undefined.
For _POSIX_C_SOURCE and _XOPEN_SOURCE the standards are very explicit.
You must define them before including ANY system headers. If you're
including a header from another library or part of your program that
might include system headers, then of course you must define the
"feature test macro" (as POSIX calls them) before including those
headers as well. The best place to do it is -D on the compiler command
line.
Rich
More information about the MPlayer-cvslog
mailing list