g++ -Ddebian -D_GNU_SOURCE -g -O2 -fno-rtti -fno-exceptions -Wall
-Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE foobar.cc -c
What are the effects of the -D options?
-Ddebian
-D_GNU_SOURCE
-DUSE_TERMIO
-DKLUDGELINEMODE
The gcc manual states:
-D name
Predefine name as a macro, with definition 1.
I tried to locate references using:
grep debian *.cc *.h
grep _GNU_SOURCE *.cc *.h
These return nothing.
I did however find #ifdef and #ifndef references for USE_TERMIO and
KLUDGELINEMODE.
Presumably, the -DUSE_TERMIO -DKLUDGELINEMODE options cause inclusion of the
enclosed definitions (or exclusion in the case of #ifndef).
What about the -Ddebian -D_GNU_SOURCE options? Can I just drop these?
FYI, The packages sources are the separated client component of
the netkit-telnet package and am trying to achieve a build using
autotools.
Regards,
Mark.
--
Mark Hobley,
393 Quinton Road West,
Quinton, BIRMINGHAM.
B32 1QE.
> I have some C++ package files, which are currently compiled using a
> command line syntax as follows:
>
> g++ -Ddebian -D_GNU_SOURCE -g -O2 -fno-rtti -fno-exceptions -Wall
> -Wno-trigraphs -DUSE_TERMIO -DKLUDGELINEMODE foobar.cc -c
>
> What are the effects of the -D options?
>
> -Ddebian
I've never seen that one before.
> -D_GNU_SOURCE
That one is quite common in system header files.
> Presumably, the -DUSE_TERMIO -DKLUDGELINEMODE options cause inclusion of
> the enclosed definitions (or exclusion in the case of #ifndef).
Yes.
> What about the -Ddebian -D_GNU_SOURCE options? Can I just drop these?
_GNU_SOURCE is probably used to include or exclude stuff in the
system header files.
The main factor in deciding if they are needed or not is if the
code compiles correctly without them. If it compiles correctly
without these defines then they aren't beeded.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"When your hammer is C++, everything begins to look like a thumb."
-- Steve Haflich, in comp.lang.c++
> What are the effects of the -D options?
>
> -Ddebian
> -D_GNU_SOURCE
> -DUSE_TERMIO
> -DKLUDGELINEMODE
Run gcc -c, with and without -E, one file at the time, one -D at the time,
and save the output of each run into a different file. Compare the files
and you'll see that the effects are.
-- H
These effectivly insert #defines in the preprocessor stage. Hence if you
compile with -Ddebian, and in your code you have
#ifdef debian
some code
#else
some other code
#endif
The -Ddebian is equivalent to inserting a line which says
#define debian
at the top of the C file you're currently compiling.
Instead of debian you could substute BobTheBuilder and it would still do the
same. It's just a symbol. The _GNU_SOURCE has a particular meaning in the
GNU C library (and a few other places) - it makes the header recognise
certain GNU extensions which are not quite POSIX-compliant (e.g. if you want
to have the strsignal() function available in string.h you have to define
_GNU_SOURCE before including it - you can do that using this flag).
Cheers,
- Daniel
--
*************************************************************************
* Daniel Franklin - Lecturer in Computer Engineering
* University of Wollongong, NSW, Australia * d.franklin at ieee.org
*************************************************************************
> Mark Hobley wrote:
>>
>> What are the effects of the -D options?
>>
>> -Ddebian
[...]
> These effectivly insert #defines in the preprocessor stage. Hence if you
> compile with -Ddebian, and in your code you have
>
> #ifdef debian
> some code
> #else
> some other code
> #endif
>
> The -Ddebian is equivalent to inserting a line which says
>
> #define debian
>
> at the top of the C file you're currently compiling.
Possibly worth mentioning for the OP that anyone who actually used
-Ddebian
or
#ifdef debian
in their code deserves a slap. Anything that builds on Debian should
be portable to any other GNU or POSIX platform, and so Debian-specific
code is never a good idea.
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.