| <html lang="en"> |
| <head> |
| <title>Preprocessing and conditional compilation - The GNU Fortran Compiler</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="The GNU Fortran Compiler"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Introduction.html#Introduction" title="Introduction"> |
| <link rel="prev" href="GNU-Fortran-and-GCC.html#GNU-Fortran-and-GCC" title="GNU Fortran and GCC"> |
| <link rel="next" href="GNU-Fortran-and-G77.html#GNU-Fortran-and-G77" title="GNU Fortran and G77"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| Copyright (C) 1999-2013 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Funding Free Software'', the Front-Cover |
| Texts being (a) (see below), and with the Back-Cover Texts being (b) |
| (see below). A copy of the license is included in the section entitled |
| ``GNU Free Documentation License''. |
| |
| (a) The FSF's Front-Cover Text is: |
| |
| A GNU Manual |
| |
| (b) The FSF's Back-Cover Text is: |
| |
| You have freedom to copy and modify this GNU Manual, like GNU |
| software. Copies published by the Free Software Foundation raise |
| funds for GNU development.--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Preprocessing-and-conditional-compilation"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="GNU-Fortran-and-G77.html#GNU-Fortran-and-G77">GNU Fortran and G77</a>, |
| Previous: <a rel="previous" accesskey="p" href="GNU-Fortran-and-GCC.html#GNU-Fortran-and-GCC">GNU Fortran and GCC</a>, |
| Up: <a rel="up" accesskey="u" href="Introduction.html#Introduction">Introduction</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">1.3 Preprocessing and conditional compilation</h3> |
| |
| <p><a name="index-CPP-4"></a><a name="index-FPP-5"></a><a name="index-Conditional-compilation-6"></a><a name="index-Preprocessing-7"></a><a name="index-preprocessor_002c-include-file-handling-8"></a> |
| 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 |
| filename extension is <samp><span class="file">.F</span></samp>, <samp><span class="file">.FOR</span></samp>, <samp><span class="file">.FTN</span></samp>, <samp><span class="file">.fpp</span></samp>, |
| <samp><span class="file">.FPP</span></samp>, <samp><span class="file">.F90</span></samp>, <samp><span class="file">.F95</span></samp>, <samp><span class="file">.F03</span></samp> or <samp><span class="file">.F08</span></samp>. To manually |
| invoke the preprocessor on any file, use <samp><span class="option">-cpp</span></samp>, to disable |
| preprocessing on files where the preprocessor is run automatically, use |
| <samp><span class="option">-nocpp</span></samp>. |
| |
| <p>If a preprocessed file includes another file with the Fortran <code>INCLUDE</code> |
| statement, the included file is not preprocessed. To preprocess included |
| files, use the equivalent preprocessor statement <code>#include</code>. |
| |
| <p>If GNU Fortran invokes the preprocessor, <code>__GFORTRAN__</code> |
| is defined and <code>__GNUC__</code>, <code>__GNUC_MINOR__</code> and |
| <code>__GNUC_PATCHLEVEL__</code> can be used to determine the version of the |
| compiler. See <a href="../cpp/index.html#Top">Overview</a> for details. |
| |
| <p>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 (<a href="http://www.daniellnagle.com/coco.html">http://www.daniellnagle.com/coco.html</a>). |
| |
| <!-- --> |
| <!-- GNU Fortran and G77 --> |
| <!-- --> |
| </body></html> |
| |