Re: -ansi, POSIX etc basic questions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phil Prentice wrote:
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??
these are not compiler definitions. They come from include files.  Presumably
they are being disabled when STDC is defined.  You probably want something like

#define _POSIX somevalueorother
#define _XOPEN_SOURCE  somevalueorother
before #including sytem files.  You'll need to consult your system
documentation (or grep /usr/include/**/*.h for their uses.
/usr/include/features.h might be a good one to look in.)


Should I be defining these definitions (as required) when I'm building the 'C' files using -ansi????

Do not define the __USE_BSD type things, use the higher level switches I just mentioned.

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?
Perhaps -E -dD will help you here.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@xxxxxxxxxxxxxxxx    ::     http://www.planetfall.pwp.blueyonder.co.uk



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux