cpp(1): Skillnad mellan sidversioner

Från Wiki.linux.se
Hoppa till navigering Hoppa till sök
(Skapade sidan med '== cpp(1) — Linux manual page == === NAME === '''cpp''' - The C Preprocessor === SYNOPSIS === <code> cpp [-D''macro''[=''defn'']...] [-U''macro''] [-I''dir''...] [-iquote''dir''...] [-M|-MM] [-MG] [-MF ''filename''] [-MP] [-MQ ''target''...] [-MT ''target''...] ''infile'' [[-o] ''outfile''] </code> Only the most useful options are given above; see below for a more complete list of preprocessor-specific options. In addition, '''cpp''' accepts most '''gcc''' driver opt...')
 
(Ingen skillnad)

Nuvarande version från 11 februari 2025 kl. 18.29

cpp(1) — Linux manual page

NAME

cpp - The C Preprocessor

SYNOPSIS

cpp [-Dmacro[=defn]...] [-Umacro] [-Idir...] [-iquotedir...] [-M|-MM] [-MG] [-MF filename] [-MP] [-MQ target...] [-MT target...] infile [[-o] outfile] Only the most useful options are given above; see below for a more complete list of preprocessor-specific options. In addition, cpp accepts most gcc driver options, which are not listed here. Refer to the GCC documentation for details.

DESCRIPTION

The C preprocessor, often known as cpp, is a macro processor that is used automatically by the C compiler to transform your program before compilation. It allows you to define macros, which are brief abbreviations for longer constructs.

The C preprocessor is intended to be used only with C, C++, and Objective-C source code. In the past, it has been abused as a general text processor. It will choke on input which does not obey C's lexical rules. For example, apostrophes will be interpreted as the beginning of character constants, and cause errors. Also, you cannot rely on it preserving characteristics of the input which are not significant to C-family languages. If a Makefile is preprocessed, all the hard tabs will be removed, and the Makefile will not work.

Having said that, you can often get away with using cpp on things which are not C. Other Algol-ish programming languages are often safe (Ada, etc.) So is assembly, with caution. -traditional-cpp mode preserves more white space, and is otherwise more permissive. Many of the problems can be avoided by writing C or C++ style comments instead of native language comments, and keeping macros simple.

Wherever possible, you should use a preprocessor geared to the language you are writing in. Modern versions of the GNU assembler have macro facilities. Most high-level programming languages have their own conditional compilation and inclusion mechanisms. If all else fails, try a true general text processor, such as GNU M4.

C preprocessors vary in some details. This manual discusses the GNU C preprocessor, which provides a small superset of the features of ISO Standard C. In its default mode, the GNU C preprocessor does not do a few things required by the standard. These are features which are rarely, if ever, used, and may cause surprising changes to the meaning of a program which does not expect them. To get strict ISO Standard C, you should use the -std=c90, -std=c99, -std=c11, or -std=c17 options, depending on which version of the standard you want. To get all the mandatory diagnostics, you must also use -pedantic.

This manual describes the behavior of the ISO preprocessor. To minimize gratuitous differences, where the ISO preprocessor's behavior does not conflict with traditional semantics, the traditional preprocessor should behave the same way. The various differences that do exist are detailed in the section Traditional Mode.

For clarity, unless noted otherwise, references to CPP in this manual refer to GNU CPP.

OPTIONS

The cpp command expects two file names as arguments, infile and outfile. The preprocessor reads infile together with any other files it specifies with #include. All the output generated by the combined input files is written in outfile.

Either infile or outfile may be -, which as infile means to read from standard input and as outfile means to write to standard output. If either file is omitted, it means the same as if - had been specified for that file. You can also use the -o outfile option to specify the output file.

Unless otherwise noted, or the option ends in =, all options which take an argument may have that argument appear either immediately after the option, or with a space between option and argument: -Ifoo and -I foo have the same effect.

Many options have multi-letter names; therefore multiple single-letter options may not be grouped: -dM is very different from -d -M.

ENVIRONMENT

This section describes the environment variables that affect how CPP operates. You can use them to specify directories or prefixes to use when searching for include files, or to control dependency output.

Note that you can also specify places to search using options such as -I, and control dependency output with options like -M. These take precedence over environment variables, which in turn take precedence over the configuration of GCC.

CPATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, and OBJC_INCLUDE_PATH specify directories for header files. Each variable's value is a list of directories separated by a special character, much like PATH. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon.

DEPENDENCIES_OUTPUT and SUNPRO_DEPENDENCIES control the output of dependencies for Make.

SOURCE_DATE_EPOCH specifies a UNIX timestamp to be used in replacement of the current date and time in the __DATE__ and __TIME__ macros, so that the embedded timestamps become reproducible.

SEE ALSO

gpl(7), gfdl(7), fsf-funding(7), gcc(1), and the Info entries for cpp and gcc.

COPYRIGHT

Copyright (c) 1987-2019 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. A copy of the license is included in the man page gfdl(7). This manual contains no Invariant Sections. The Front-Cover Texts are (a) (see below), and the Back-Cover Texts are (b) (see below).

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

COLOPHON

This page is part of the gcc (GNU Compiler Collection) project. Information about the project can be found at [1]. If you have a bug report for this manual page, see [2].

Sidslut

Orginalhemsidan på Engelska :https://man7.org/linux/man-pages/man1/cpp.1.html


Det här är en maskinöversättning av Linux man sidor till svenska. Om du hittar fel är vi tacksamma om du rapporterar dem via formuläret som finns på https://www.linux.se/kontaka-linux-se/

Tack till PC-Service som har sponsrat Linux.se med webbhotell.