Next: Error and Warning Options, Previous: Fortran Dialect Options, Up: Invoking GNU Fortran [Contents][Index]

### 2.3 Enable and customize preprocessing

Preprocessor related options. See section Preprocessing and conditional compilation for more detailed information on preprocessing in `gfortran`.

`-cpp`
`-nocpp`

  Enable preprocessing. The preprocessor is automatically invoked if the file extension is `.fpp`, `.FPP`, `.F`, `.FOR`, `.FTN`, `.F90`, `.F95`, `.F03` or `.F08`. Use this option to manually enable preprocessing of any kind of Fortran file.

  To disable preprocessing of files with any of the above listed extensions, use the negative form: `-nocpp`.

  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 `-ffree-line-length-none` or `-ffixed-line-length-none` options.

`-dM`

  Instead of the normal output, generate a list of `'#define'` 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 `foo.f90`, the command

        touch foo.f90; gfortran -cpp -E -dM foo.f90

  will show all the predefined macros.

`-dD`

  Like `-dM` except in two respects: it does not include the predefined macros, and it outputs both the `#define` directives and the result of preprocessing. Both kinds of output go to the standard output file.

`-dN`

  Like `-dD`, but emit only the macro names, not their expansions.

`-dU`

  Like `dD` 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 `'#undef'` directives are also output for macros tested but undefined at the time.

`-dI`

  Output `'#include'` directives in addition to the result of preprocessing.

`-fworking-directory`

  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 `-fno-working-directory`. If the `-P` flag is present in the command line, this option has no effect, since no `#line` directives are emitted whatsoever.

`-idirafter dir`

  Search dir for include files, but do it after all directories specified with `-I` and the standard system directories have been exhausted. dir is treated as a system include directory. If dir begins with `=`, then the `=` will be replaced by the sysroot prefix; see `--sysroot` and `-isysroot`.

`-imultilib dir`

  Use dir as a subdirectory of the directory containing target-specific C++ headers.

`-iprefix prefix`

  Specify prefix as the prefix for subsequent `-iwithprefix` options. If the prefix represents a directory, you should include the final `'/'`.

`-isysroot dir`

  This option is like the `--sysroot` option, but applies only to header files. See the `--sysroot` option for more information.

`-iquote dir`

  Search dir only for header files requested with `#include "file"`; they are not searched for `#include <file>`, before all directories specified by `-I` and before the standard system directories. If dir begins with `=`, then the `=` will be replaced by the sysroot prefix; see `--sysroot` and `-isysroot`.

`-isystem dir`

  Search dir for header files, after all directories specified by `-I` 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 dir begins with `=`, then the `=` will be replaced by the sysroot prefix; see `--sysroot` and `-isysroot`.

`-nostdinc`

  Do not search the standard system directories for header files. Only the directories you have specified with `-I` options (and the directory of the current file, if appropriate) are searched.

`-undef`

  Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined.

`-Apredicate=answer`

  Make an assertion with the predicate predicate and answer answer. This form is preferred to the older form -A predicate(answer), which is still supported, because it does not use shell special characters.

`-A-predicate=answer`

  Cancel an assertion with the predicate predicate and answer answer.

`-C`

  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.

  You should be prepared for side effects when using `-C`; 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 `'#'`.

  Warning: this currently handles C-Style comments only. The preprocessor does not yet recognize Fortran-style comments.

`-CC`

  Do not discard comments, including during macro expansion. This is like `-C`, except that comments contained within macros are also passed through to the output file where the macro is expanded.

  In addition to the side-effects of the `-C` option, the `-CC` 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 `-CC` option is generally used to support lint comments.

  Warning: this currently handles C- and C++-Style comments only. The preprocessor does not yet recognize Fortran-style comments.

`-Dname`

  Predefine name as a macro, with definition `1`.

`-Dname=definition`

  The contents of definition are tokenized and processed as if they appeared during translation phase three in a `'#define'` directive. In particular, the definition will be truncated by embedded newline characters.

  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.

  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, `-D'name(args...)=definition'` works.

  `-D` and `-U` 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.

`-H`

  Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the `'#include'` stack it is.

`-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.

`-Uname`

  Cancel any previous definition of name, either built in or provided with a `-D` option.

Next: Error and Warning Options, Previous: Fortran Dialect Options, Up: Invoking GNU Fortran [Contents][Index]