Re: g++ -D compiler options



Mark Hobley wrote:

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