[FFmpeg-devel] [PATCH][RFC] -std=c99

Måns Rullgård mans
Tue Aug 12 23:04:57 CEST 2008


Michael Niedermayer <michaelni at gmx.at> writes:

> On Tue, Aug 12, 2008 at 08:56:12PM +0100, M?ns Rullg?rd wrote:
>> Michael Niedermayer <michaelni at gmx.at> writes:
>> 
>> > Hi
>> >
>> > the patch below adds -std=c99 to the cflags when supported.  The
>> > advanatges this has is that the compiler uses C99 semantics, that
>> > several non C99 features and declarations become disabled by
>> > default and thus cannot so easily be used mistakely.
>> >
>> > Compilation and regression tests pass for me.
>> >
>> > -fasm is needed for
>> >     asm()
>> >
>> > -D_BSD_SOURCE is needed for
>> >     strncasecmp()
>> >     inet_aton()
>> >     gethostname()
>> >     fd_set()
>> >     FD_ZERO
>> >     FD_SET
>> >     FD_ISSET
>> >
>> > -D_POSIX_C_SOURCE is needed for:
>> >     getaddrinfo()
>> >     gai_strerror()
>> >     freeaddrinfo()
>> >     AI_PASSIVE
>> >     getnameinfo()
>> >
>> > -D_POSIX_C_SOURCE=2 is needed for:
>> >     optind
>> >     optarg
>> >     getopt()
>> >
>> > The defines are likely needed for more than what i have listed
>> > above, these where just amongth the first that showed up without
>> > the specfic option
>> 
>> Something like this has been on my low-priority TODO list (i.e. things
>> that I'd like to do, but probably never will) for some time.
>> 
>> _POSIX_C_SOURCE and _XOPEN_SOURCE are standard feature selection
>> macros, so using those is preferred over the glibc-specific ones.
>> Setting _BSD_SOURCE is slightly dangerous, since it makes glibc
>> replace a few standard functions with BSD-compatible functions of the
>> same name.
>
> according to the actual headers
>
> /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX.  */
> #if defined _BSD_SOURCE && \
>     !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
>       defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
>       defined _GNU_SOURCE || defined _SVID_SOURCE)
> # define __FAVOR_BSD    1
> #endif
>
> so because we did define _POSIX_C_SOURCE bsd would not be favored

I forgot about that bit.

> as far as i can see,

That's the trouble with glibc, visibility is very poor.

(Go on Uoti, take that half sentence out of context, and flame a bit.)

> i ve not checked the docs as i dont trust them
> anyway.

I don't trust the docs to be accurate, and I don't trust the headers
to not change.  In fact, I don't trust glibc.  Nor Ulrich Drepper.

>> Most (all?) of the above-mentioned functions are POSIX standard, so
>> there should be no need for _BSD_SOURCE.  If anything does require
>> this, we should look for a POSIX alternative.
>
> Ill try again with xopen and posix and without bsd

You're racing with Baptiste on this.  I recommend both of you hold off
any commits, and send patches first.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list