diff options
Diffstat (limited to 'share/doc/gfortran/Preprocessing-Options.html')
-rw-r--r-- | share/doc/gfortran/Preprocessing-Options.html | 390 |
1 files changed, 390 insertions, 0 deletions
diff --git a/share/doc/gfortran/Preprocessing-Options.html b/share/doc/gfortran/Preprocessing-Options.html new file mode 100644 index 0000000..19a10b0 --- /dev/null +++ b/share/doc/gfortran/Preprocessing-Options.html @@ -0,0 +1,390 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<!-- Copyright (C) 1999-2023 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. --> +<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> +<head> +<title>The GNU Fortran Compiler: Preprocessing Options</title> + +<meta name="description" content="The GNU Fortran Compiler: Preprocessing Options"> +<meta name="keywords" content="The GNU Fortran Compiler: Preprocessing Options"> +<meta name="resource-type" content="document"> +<meta name="distribution" content="global"> +<meta name="Generator" content="makeinfo"> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> +<link href="index.html#Top" rel="start" title="Top"> +<link href="Option-Index.html#Option-Index" rel="index" title="Option Index"> +<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> +<link href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" rel="up" title="Invoking GNU Fortran"> +<link href="Error-and-Warning-Options.html#Error-and-Warning-Options" rel="next" title="Error and Warning Options"> +<link href="Fortran-Dialect-Options.html#Fortran-Dialect-Options" rel="previous" title="Fortran Dialect Options"> +<style type="text/css"> +<!-- +a.summary-letter {text-decoration: none} +blockquote.smallquotation {font-size: smaller} +div.display {margin-left: 3.2em} +div.example {margin-left: 3.2em} +div.indentedblock {margin-left: 3.2em} +div.lisp {margin-left: 3.2em} +div.smalldisplay {margin-left: 3.2em} +div.smallexample {margin-left: 3.2em} +div.smallindentedblock {margin-left: 3.2em; font-size: smaller} +div.smalllisp {margin-left: 3.2em} +kbd {font-style:oblique} +pre.display {font-family: inherit} +pre.format {font-family: inherit} +pre.menu-comment {font-family: serif} +pre.menu-preformatted {font-family: serif} +pre.smalldisplay {font-family: inherit; font-size: smaller} +pre.smallexample {font-size: smaller} +pre.smallformat {font-family: inherit; font-size: smaller} +pre.smalllisp {font-size: smaller} +span.nocodebreak {white-space:nowrap} +span.nolinebreak {white-space:nowrap} +span.roman {font-family:serif; font-weight:normal} +span.sansserif {font-family:sans-serif; font-weight:normal} +ul.no-bullet {list-style: none} +--> +</style> + + +</head> + +<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> +<a name="Preprocessing-Options"></a> +<div class="header"> +<p> +Next: <a href="Error-and-Warning-Options.html#Error-and-Warning-Options" accesskey="n" rel="next">Error and Warning Options</a>, Previous: <a href="Fortran-Dialect-Options.html#Fortran-Dialect-Options" accesskey="p" rel="previous">Fortran Dialect Options</a>, Up: <a href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" accesskey="u" rel="up">Invoking GNU Fortran</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p> +</div> +<hr> +<a name="Enable-and-customize-preprocessing"></a> +<h3 class="section">2.3 Enable and customize preprocessing</h3> +<a name="index-preprocessor"></a> +<a name="index-options_002c-preprocessor"></a> +<a name="index-CPP"></a> +<a name="index-FPP"></a> +<a name="index-Conditional-compilation"></a> +<a name="index-Preprocessing"></a> +<a name="index-preprocessor_002c-include-file-handling"></a> + +<p>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>.F</samp>, <samp>.FOR</samp>, <samp>.FTN</samp>, <samp>.fpp</samp>, +<samp>.FPP</samp>, <samp>.F90</samp>, <samp>.F95</samp>, <samp>.F03</samp> or <samp>.F08</samp>. To manually +invoke the preprocessor on any file, use <samp>-cpp</samp>, to disable +preprocessing on files where the preprocessor is run automatically, use +<samp>-nocpp</samp>. +</p> +<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> +<p>If GNU Fortran invokes the preprocessor, <code>__GFORTRAN__</code> +is defined. The macros <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="http://gcc.gnu.org/onlinedocs/cpp/index.html#Top">Overview</a> in <cite>The C Preprocessor</cite> for details. +</p> +<p>GNU Fortran supports a number of <code>INTEGER</code> and <code>REAL</code> kind types +in additional to the kind types required by the Fortran standard. +The availability of any given kind type is architecture dependent. The +following pre-defined preprocessor macros can be used to conditionally +include code for these additional kind types: <code>__GFC_INT_1__</code>, +<code>__GFC_INT_2__</code>, <code>__GFC_INT_8__</code>, <code>__GFC_INT_16__</code>, +<code>__GFC_REAL_10__</code>, and <code>__GFC_REAL_16__</code>. +</p> +<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>). +</p> +<p>The following options control preprocessing of Fortran code: +</p> +<dl compact="compact"> +<dd><a name="index-cpp"></a> +<a name="index-fpp"></a> +<a name="index-preprocessor_002c-enable"></a> +<a name="index-preprocessor_002c-disable"></a> +</dd> +<dt><code>-cpp</code></dt> +<dt><code>-nocpp</code></dt> +<dd><p>Enable preprocessing. The preprocessor is automatically invoked if +the file extension is <samp>.fpp</samp>, <samp>.FPP</samp>, <samp>.F</samp>, <samp>.FOR</samp>, +<samp>.FTN</samp>, <samp>.F90</samp>, <samp>.F95</samp>, <samp>.F03</samp> or <samp>.F08</samp>. Use +this option to manually enable preprocessing of any kind of Fortran file. +</p> +<p>To disable preprocessing of files with any of the above listed extensions, +use the negative form: <samp>-nocpp</samp>. +</p> +<p>The preprocessor is run in traditional mode. Any restrictions of the +file-format, especially the limits on line length, apply for +preprocessed output as well, so it might be advisable to use the +<samp>-ffree-line-length-none</samp> or <samp>-ffixed-line-length-none</samp> +options. +</p> +<a name="index-dM"></a> +<a name="index-preprocessor_002c-debugging"></a> +<a name="index-debugging_002c-preprocessor"></a> +</dd> +<dt><code>-dM</code></dt> +<dd><p>Instead of the normal output, generate a list of <code>'#define'</code> +directives for all the macros defined during the execution of the +preprocessor, including predefined macros. This gives you a way +of finding out what is predefined in your version of the preprocessor. +Assuming you have no file <samp>foo.f90</samp>, the command +</p><div class="smallexample"> +<pre class="smallexample"> touch foo.f90; gfortran -cpp -E -dM foo.f90 +</pre></div> +<p>will show all the predefined macros. +</p> +<a name="index-dD"></a> +<a name="index-preprocessor_002c-debugging-1"></a> +<a name="index-debugging_002c-preprocessor-1"></a> +</dd> +<dt><code>-dD</code></dt> +<dd><p>Like <samp>-dM</samp> except in two respects: it does not include the +predefined macros, and it outputs both the <code>#define</code> directives +and the result of preprocessing. Both kinds of output go to the +standard output file. +</p> +<a name="index-dN"></a> +<a name="index-preprocessor_002c-debugging-2"></a> +<a name="index-debugging_002c-preprocessor-2"></a> +</dd> +<dt><code>-dN</code></dt> +<dd><p>Like <samp>-dD</samp>, but emit only the macro names, not their expansions. +</p> +<a name="index-dU"></a> +<a name="index-preprocessor_002c-debugging-3"></a> +<a name="index-debugging_002c-preprocessor-3"></a> +</dd> +<dt><code>-dU</code></dt> +<dd><p>Like <samp>dD</samp> except that only macros that are expanded, or whose +definedness is tested in preprocessor directives, are output; the +output is delayed until the use or test of the macro; and <code>'#undef'</code> +directives are also output for macros tested but undefined at the time. +</p> +<a name="index-dI"></a> +<a name="index-preprocessor_002c-debugging-4"></a> +<a name="index-debugging_002c-preprocessor-4"></a> +</dd> +<dt><code>-dI</code></dt> +<dd><p>Output <code>'#include'</code> directives in addition to the result +of preprocessing. +</p> +<a name="index-fworking_002ddirectory"></a> +<a name="index-preprocessor_002c-working-directory"></a> +</dd> +<dt><code>-fworking-directory</code></dt> +<dd><p>Enable generation of linemarkers in the preprocessor output that will +let the compiler know the current working directory at the time of +preprocessing. When this option is enabled, the preprocessor will emit, +after the initial linemarker, a second linemarker with the current +working directory followed by two slashes. GCC will use this directory, +when it is present in the preprocessed input, as the directory emitted +as the current working directory in some debugging information formats. +This option is implicitly enabled if debugging information is enabled, +but this can be inhibited with the negated form +<samp>-fno-working-directory</samp>. If the <samp>-P</samp> flag is present +in the command line, this option has no effect, since no <code>#line</code> +directives are emitted whatsoever. +</p> +<a name="index-idirafter-dir"></a> +<a name="index-preprocessing_002c-include-path"></a> +</dd> +<dt><code>-idirafter <var>dir</var></code></dt> +<dd><p>Search <var>dir</var> for include files, but do it after all directories +specified with <samp>-I</samp> and the standard system directories have +been exhausted. <var>dir</var> is treated as a system include directory. +If dir begins with <code>=</code>, then the <code>=</code> will be replaced by +the sysroot prefix; see <samp>--sysroot</samp> and <samp>-isysroot</samp>. +</p> +<a name="index-imultilib-dir"></a> +<a name="index-preprocessing_002c-include-path-1"></a> +</dd> +<dt><code>-imultilib <var>dir</var></code></dt> +<dd><p>Use <var>dir</var> as a subdirectory of the directory containing target-specific +C++ headers. +</p> +<a name="index-iprefix-prefix"></a> +<a name="index-preprocessing_002c-include-path-2"></a> +</dd> +<dt><code>-iprefix <var>prefix</var></code></dt> +<dd><p>Specify <var>prefix</var> as the prefix for subsequent <samp>-iwithprefix</samp> +options. If the <var>prefix</var> represents a directory, you should include +the final <code>'/'</code>. +</p> +<a name="index-isysroot-dir"></a> +<a name="index-preprocessing_002c-include-path-3"></a> +</dd> +<dt><code>-isysroot <var>dir</var></code></dt> +<dd><p>This option is like the <samp>--sysroot</samp> option, but applies only to +header files. See the <samp>--sysroot</samp> option for more information. +</p> +<a name="index-iquote-dir"></a> +<a name="index-preprocessing_002c-include-path-4"></a> +</dd> +<dt><code>-iquote <var>dir</var></code></dt> +<dd><p>Search <var>dir</var> only for header files requested with <code>#include "file"</code>; +they are not searched for <code>#include <file></code>, before all directories +specified by <samp>-I</samp> and before the standard system directories. If +<var>dir</var> begins with <code>=</code>, then the <code>=</code> will be replaced by the +sysroot prefix; see <samp>--sysroot</samp> and <samp>-isysroot</samp>. +</p> +<a name="index-isystem-dir"></a> +<a name="index-preprocessing_002c-include-path-5"></a> +</dd> +<dt><code>-isystem <var>dir</var></code></dt> +<dd><p>Search <var>dir</var> for header files, after all directories specified by +<samp>-I</samp> but before the standard system directories. Mark it as a +system directory, so that it gets the same special treatment as is +applied to the standard system directories. If <var>dir</var> begins with +<code>=</code>, then the <code>=</code> will be replaced by the sysroot prefix; +see <samp>--sysroot</samp> and <samp>-isysroot</samp>. +</p> +<a name="index-nostdinc"></a> +</dd> +<dt><code>-nostdinc</code></dt> +<dd><p>Do not search the standard system directories for header files. Only +the directories you have specified with <samp>-I</samp> options (and the +directory of the current file, if appropriate) are searched. +</p> +<a name="index-undef"></a> +</dd> +<dt><code>-undef</code></dt> +<dd><p>Do not predefine any system-specific or GCC-specific macros. +The standard predefined macros remain defined. +</p> +<a name="index-Apredicate_003danswer"></a> +<a name="index-preprocessing_002c-assertion"></a> +</dd> +<dt><code>-A<var>predicate</var>=<var>answer</var></code></dt> +<dd><p>Make an assertion with the predicate <var>predicate</var> and answer <var>answer</var>. +This form is preferred to the older form -A predicate(answer), which is still +supported, because it does not use shell special characters. +</p> +<a name="index-A_002dpredicate_003danswer"></a> +<a name="index-preprocessing_002c-assertion-1"></a> +</dd> +<dt><code>-A-<var>predicate</var>=<var>answer</var></code></dt> +<dd><p>Cancel an assertion with the predicate <var>predicate</var> and answer <var>answer</var>. +</p> +<a name="index-C"></a> +<a name="index-preprocessing_002c-keep-comments"></a> +</dd> +<dt><code>-C</code></dt> +<dd><p>Do not discard comments. All comments are passed through to the output +file, except for comments in processed directives, which are deleted +along with the directive. +</p> +<p>You should be prepared for side effects when using <samp>-C</samp>; it causes +the preprocessor to treat comments as tokens in their own right. For example, +comments appearing at the start of what would be a directive line have the +effect of turning that line into an ordinary source line, since the first +token on the line is no longer a <code>'#'</code>. +</p> +<p>Warning: this currently handles C-Style comments only. The preprocessor +does not yet recognize Fortran-style comments. +</p> +<a name="index-CC"></a> +<a name="index-preprocessing_002c-keep-comments-1"></a> +</dd> +<dt><code>-CC</code></dt> +<dd><p>Do not discard comments, including during macro expansion. This is like +<samp>-C</samp>, except that comments contained within macros are also passed +through to the output file where the macro is expanded. +</p> +<p>In addition to the side-effects of the <samp>-C</samp> option, the <samp>-CC</samp> +option causes all C++-style comments inside a macro to be converted to C-style +comments. This is to prevent later use of that macro from inadvertently +commenting out the remainder of the source line. The <samp>-CC</samp> option +is generally used to support lint comments. +</p> +<p>Warning: this currently handles C- and C++-Style comments only. The +preprocessor does not yet recognize Fortran-style comments. +</p> +<a name="index-Dname"></a> +<a name="index-preprocessing_002c-define-macros"></a> +</dd> +<dt><code>-D<var>name</var></code></dt> +<dd><p>Predefine name as a macro, with definition <code>1</code>. +</p> +<a name="index-Dname_003ddefinition"></a> +<a name="index-preprocessing_002c-define-macros-1"></a> +</dd> +<dt><code>-D<var>name</var>=<var>definition</var></code></dt> +<dd><p>The contents of <var>definition</var> are tokenized and processed as if they +appeared during translation phase three in a <code>'#define'</code> directive. +In particular, the definition will be truncated by embedded newline +characters. +</p> +<p>If you are invoking the preprocessor from a shell or shell-like program +you may need to use the shell’s quoting syntax to protect characters such +as spaces that have a meaning in the shell syntax. +</p> +<p>If you wish to define a function-like macro on the command line, write +its argument list with surrounding parentheses before the equals sign +(if any). Parentheses are meaningful to most shells, so you will need +to quote the option. With sh and csh, <code>-D'name(args...)=definition'</code> +works. +</p> +<p><samp>-D</samp> and <samp>-U</samp> options are processed in the order they are +given on the command line. All -imacros file and -include file options +are processed after all -D and -U options. +</p> +<a name="index-H"></a> +</dd> +<dt><code>-H</code></dt> +<dd><p>Print the name of each header file used, in addition to other normal +activities. Each name is indented to show how deep in the <code>'#include'</code> +stack it is. +</p> +<a name="index-P"></a> +<a name="index-preprocessing_002c-no-linemarkers"></a> +</dd> +<dt><code>-P</code></dt> +<dd><p>Inhibit generation of linemarkers in the output from the preprocessor. +This might be useful when running the preprocessor on something that +is not C code, and will be sent to a program which might be confused +by the linemarkers. +</p> +<a name="index-Uname"></a> +<a name="index-preprocessing_002c-undefine-macros"></a> +</dd> +<dt><code>-U<var>name</var></code></dt> +<dd><p>Cancel any previous definition of <var>name</var>, either built in or provided +with a <samp>-D</samp> option. +</p></dd> +</dl> + + +<hr> +<div class="header"> +<p> +Next: <a href="Error-and-Warning-Options.html#Error-and-Warning-Options" accesskey="n" rel="next">Error and Warning Options</a>, Previous: <a href="Fortran-Dialect-Options.html#Fortran-Dialect-Options" accesskey="p" rel="previous">Fortran Dialect Options</a>, Up: <a href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" accesskey="u" rel="up">Invoking GNU Fortran</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p> +</div> + + + +</body> +</html> |