This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -ansi, POSIX etc basic questions?

On Fri, Sep 24, 2004 at 11:29:29AM +0100, Phil Prentice took 34 lines to write:
> Hi
>   I have some basic questions around compiler definitions.  I am porting some 
> code which contains a mixture of BSD & SVR4 from Solaris to Linux.
>   Forgive me if some of these questions are rather basic.
>   1)  I have been using the -ansi flag definition, because that seemed the 
> right thing to do?  I seem to remember that -ansi will (where possible) check 
> prototyping and will define the __STDC__ definition.
>        Am I correct to be trying to use this -ansi flag????

It depends, I suppose, on what you want to accomplish using -ansi. It
enables support for C90, which turns off GCC features that are incompatible
with C90. IIRC, -ansi also defines __STRICT_ANSI__, which makes functions
and macros undefined. "info gcc Invoking C" should be a good start.

>   2)  The sad thing is that if I use the -ansi flag it stops many of the 'C'  
> files from compiling. For example MAXNAMLEN will be undefined or things like 
> u_long or S_IFDIR will not be defined.  I presume that this is related to 
> compiler definitions like __USE_BSD or __USE_POSIX or __USE_XOPEN etc
>        Presumably -ansi is automatically turning some of these compiler 
> definitions off??
>       Should I be defining these definitions (as required) when I'm building 
> the 'C' files using -ansi????

Perhaps including the correct headers will be sufficient?

Lockwood's Long Shot:
	The chances of getting eaten up by a lion on Main Street aren't
one in a million, but once would be enough.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]