Re: #ifdef
From: Dave Thompson (david.thompson1_at_worldnet.att.net)
Date: 09/23/04
- Next message: Dave Thompson: "Re: Q: Type'ing the infamous 'flags' field"
- Previous message: Arthur J. O'Dwyer: "Re: Pop's Device, was Re: Some Newb Problem with "int", please help."
- In reply to: Benjamin Ketcham: "Re: #ifdef"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Sep 2004 05:07:40 GMT
On Fri, 17 Sep 2004 10:12:39 -0000, Benjamin Ketcham
<bketcham@drizzle.com> wrote:
> Hash <a@b.com> wrote:
> > I have a small doubt,
> >
> > #ifdef _BSD
> >
> > When we use #ifdef preprocessor directive, the parameter which we pass
> > (in this case _BSD) is it defined by the user or is it defined somewhere
> > else?
> >
> > If the definition is somewhere where can i find the defnitions ?
>
> It may be defined by the user, or somewhere in a header file,
> or in other project files such as "Makefile". If the documentation
> is any good, it should tell you what symbols are defined, and where.
> Often, especially under Unix and its ilk, compiling software
> is a two step process: the first step, "configure", queries your
> system and creates one or more header files containing bunches of
> macro definitions representing what kind of system it is; the
> second step, "make", then [compiles using these definitions....]
> I would expect the symbol in question, "_BSD", to be defined
> automatically for you, if it is needed, either in a header file
> that is part of the software package, or in a system header file
> (often located under /usr/include on Unix), or as part of the
> "configure" process.
>
Agree so far, but especially for macros beginning with underscore
there is a third possibility -- they may be "builtin" to the compiler,
which may mean actually hardcoded or simply set somewhere in the
compiler installation. For the particularly flexible and common case
of gcc, this is in a file (usually?) in a place something like
/usr/lib/gcc-lib/$arch/$version/specs . Either way they should be
described in the compiler's documentation.
<snip>
> Many compilers have options to verbosely print out directories
> where they are searching for header files, and to display the
> C code after preprocessing but before compiling. These can help
> in tracking down issues with preprocessor symbols.
>
This won't help for builtins however. gcc does have an option -dM to
dump out macros at the end of compilation -- which if you compile a
(perhaps dummy) program that doesn't (significantly) change the
builtins and system settings, will show you what you've got.
- David.Thompson1 at worldnet.att.net
- Next message: Dave Thompson: "Re: Q: Type'ing the infamous 'flags' field"
- Previous message: Arthur J. O'Dwyer: "Re: Pop's Device, was Re: Some Newb Problem with "int", please help."
- In reply to: Benjamin Ketcham: "Re: #ifdef"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|