In article <d1**********@ns2.fe.internet.bosch.com>,
invincible <mo**********@in.bosch.com> wrote:
I have program
void main()
{
#ifdef env_var
printf(" I am in Linux");
#endif
}
This one I can achieve using -dLinux while compiling it on linux
But I dont want to use any variables , is there any inbuilt environment var
which i can use for my required task.
No. The C standard does not require the consultation of any environment
variables at compile time.
That having been said: if you tell your compiler to show all the phases
as it compiles, you will often find that each different environment
automatically -D's different preprocessor tokens. For example, on
the machine I am on now, in the default compile mode I used,
-Dmips -DMIPSEB -D_MIPSEB -D_PIC -D__DSO__ -D__EXTENSIONS__ \
-D__INLINE_INTRINSICS -D__MATH_HAS_NO_SIDE_EFFECTS -DLANGUAGE_C -Dunix \
-Dsgi -Dhost_mips -D_SGI_SOURCE -D_LONGLONG -D_SVR4_SOURCE \
-D_LANGUAGE_C -D_MODERN_C -D__sgi -D__host_mips -D_SYSTYPE_SVR4 \
-D__unix -D_COMPILER_VERSION=730 -D__mips=3 -D_MIPS_ISA=3 -D_ABI64=3 \
-D_MIPS_SIM=_ABI64 -D_MIPS_FPSET=32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=64 \
-D_MIPS_SZPTR=64 -D_SIZE_INT=32 -D_SIZE_LONG=64 -D_SIZE_PTR=64
The exact set of tokens will be dependant on the system you are on,
on the compiler you are using, on the compiler version, and upon
compilation flags.
Note, by the way, that a preprocessor token definition is NOT an
environment variable.
--
Feep if you love VT-52's.