public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -ansi, POSIX etc basic questions?
@ 2004-09-24 14:26 Phil Prentice
  2004-09-24 20:32 ` Kurt Wall
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Prentice @ 2004-09-24 14:26 UTC (permalink / raw)
  To: gcc-help, gcc

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

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

       Any other suggestions?

       Currently in many cases I am simply defining these defn's as part of 
the C source.....not the most ideal solution.

  3)  Can I get the compiler to somehow list out the compiler definitions 
that it is using?

  Thank You very much for your time

  Phil Prentice

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: -ansi, POSIX etc basic questions?
  2004-09-24 14:26 -ansi, POSIX etc basic questions? Phil Prentice
@ 2004-09-24 20:32 ` Kurt Wall
  0 siblings, 0 replies; 2+ messages in thread
From: Kurt Wall @ 2004-09-24 20:32 UTC (permalink / raw)
  To: gcc

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?

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-24 19:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-24 14:26 -ansi, POSIX etc basic questions? Phil Prentice
2004-09-24 20:32 ` Kurt Wall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).