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

Michael Niedermayer michaelni
Tue Aug 12 22:47:54 CEST 2008


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
as far as i can see, i ve not checked the docs as i dont trust them
anyway.


> 
> 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

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080812/58055459/attachment.pgp>



More information about the ffmpeg-devel mailing list