GCC Preprocessor

S

s7master

Is there any way I can check to see what agriculture (x86_64, ppc,
ia32, etc) I am compiling with using the preprocessor? All help is
appreciated.
 
S

SM Ryan

(e-mail address removed) wrote:
# Is there any way I can check to see what agriculture (x86_64, ppc,
# ia32, etc) I am compiling with using the preprocessor? All help is
# appreciated.

There may be system specific #defines which can identify the hardware
and/or software. You can then do things like
#ifdef __APPLE__
#if OSX_VERSION>4
..
#endif
#endif
Such defines are going to be system specific and should be documented
by the system integrator, manufacturer, etc.
 
R

Richard Heathfield

(e-mail address removed) said:
Is there any way I can check to see what agriculture (x86_64, ppc,
ia32, etc) I am compiling with using the preprocessor? All help is
appreciated.

SM Ryan has already given you a reply that should field most of your
questions, but never forget you can grow your own preprocessor directives
in the event that your implementation doesn't identify itself so
conveniently. Keep them well-watered, and don't chaff at the extra workload
involved - it's amaizing just how often such a simple solution can work
really well.

Another way to deal with this problem is to crop it out completely and write
the code in a hardy perennial style, so that it doesn't matter what kind of
soil you use - the code can grow anywhere, and doesn't need any
preprocessor directives at all. In my experience, about 95% of the code can
be written that way (or even 100% in many cases), with the rest being
carefully isolated to avoid cross-pollination.

Apologies in advance (to careful readers only) for the corny reply.
 
C

Chris McDonald

Richard Heathfield said:
(e-mail address removed) said:
SM Ryan has already given you a reply that should field most of your
questions, but never forget you can grow your own preprocessor directives
in the event that your implementation doesn't identify itself so
conveniently. Keep them well-watered, and don't chaff at the extra workload
involved - it's amaizing just how often such a simple solution can work
really well.
Another way to deal with this problem is to crop it out completely and write
the code in a hardy perennial style, so that it doesn't matter what kind of
soil you use - the code can grow anywhere, and doesn't need any
preprocessor directives at all. In my experience, about 95% of the code can
be written that way (or even 100% in many cases), with the rest being
carefully isolated to avoid cross-pollination.
Apologies in advance (to careful readers only) for the corny reply.

In advance, or was the apology just for the 'corny' bit?
Or, is this a new version of bottom-posting?
 
T

Taylor K.

Thanks for the advice, I looked more into the gcc preprocessor and
found what I was looking for at
http://www.network-theory.co.uk/docs/gccintro/gccintro_34.html . 'cpp
-dM /dev/null ' was what really helped me out. Also, the macro I was
looking for is __x86_64. I bought a 64 bit processor and felt like
taking advantage of it, that's why I need to know what agriculture,
although you are right that is is not necessary. Anyways, thanks again
for the help.
 
K

Keith Thompson

Taylor K. said:
Thanks for the advice, I looked more into the gcc preprocessor and
found what I was looking for at
http://www.network-theory.co.uk/docs/gccintro/gccintro_34.html . 'cpp
-dM /dev/null ' was what really helped me out. Also, the macro I was
looking for is __x86_64. I bought a 64 bit processor and felt like
taking advantage of it, that's why I need to know what agriculture,
although you are right that is is not necessary. Anyways, thanks again
for the help.

The word you're looking for is "architecture", not "agriculture".
(Consult a dictionary for more information.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top