detecting gfortran with ifdef
Steven Bosscher
stevenb.gcc@gmail.com
Fri Oct 27 02:49:00 GMT 2006
On Thursday 26 October 2006 23:12, Warren Turkal wrote:
> Is there a preprocessor symbol defined when using gfortran that can be used
> to conditionally compile code only when using gfortran?
No, there isn't.
Note that gfortran does not have an integrated preprocessor, like
e.g. Cray Fortran does. The program you call to compile your
programs is the driver program called gfortran. This driver calls
the compiler (f951), and for some files it calls the preprocessor
before the compiler.
If your Fortran source file has the extensions .F, .fpp, .FPP, .F90,
or .F95, gfortran (the compiler driver) calls the C preprocessor in
traditional (i.e. pre ANSI C) mode. The driver adds one command
line #define to the command line: -D_LANGUAGE_FORTRAN.
So the closest thing to what you want, probably is _LANGUAGE_FORTRAN.
But I don't know if other Fortran compilers also define this for the
preprocessor, in other words I don't know if _LANGUAGE_FORTRAN is
sufficient to know for sure that gfortran is the compiler.
Do other compilers provide a preprocessor symbol? If so, could you
tell a bit more about that?
Thanks,
Gr.
Steven
More information about the Fortran
mailing list