Next: , Previous: GNU Fortran and GCC, Up: Introduction

1.3 Preprocessing and conditional compilation

Many Fortran compilers including GNU Fortran allow passing the source code through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, FPP) to allow for conditional compilation. In the case of GNU Fortran, this is the GNU C Preprocessor in the traditional mode. On systems with case-preserving file names, the preprocessor is automatically invoked if the file extension is .F, .FOR, .FTN, .F90, .F95 or .F03; otherwise use for fixed-format code the option -x f77-cpp-input and for free-format code -x f95-cpp-input. Invocation of the preprocessor can be suppressed using -x f77 or -x f95.

If the GNU Fortran invoked the preprocessor, __GFORTRAN__ is defined and __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__ can be used to determine the version of the compiler. See Overview for details.

While CPP is the de-facto standard for preprocessing Fortran code, Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines Conditional Compilation, which is not widely used and not directly supported by the GNU Fortran compiler. You can use the program coco to preprocess such files (