CPP(1)

πŸ“¦
version 14.4.0 Β· 4 versions
, in ubuntu stonking

πŸ’– CPP(1) β€” the GNU C Preprocessor πŸ’–

okay so bestie, welcome to CPP(1), aka the GNU C preprocessor, and honestly? she's iconic. let's get into it 🫢


✨ NAME ✨

cpp β€” the C Preprocessor. that's it, that's the name, short and slay πŸ’…


🌸 SYNOPSIS 🌸

cpp [-Dmacro[=defn]...] [-Umacro]
    [-Idir...] [-iquotedir...]
    [-M|-MM] [-MG] [-MF filename]
    [-MP] [-MQ target...]
    [-MT target...]
    infile [[-o] outfile]

ngl that's only the most useful options, bestie. there's a way fuller list of preprocessor-specific options down below ⬇️. also cpp accepts most of the gcc driver options too, and those are not listed here β€” go look at the GCC documentation for the tea on those πŸ“


πŸ¦‹ DESCRIPTION πŸ¦‹

so the C preprocessor β€” usually just called cpp β€” is a macro processor, and the C compiler runs it automatically to transform your program before compilation even starts ✨ the "macro processor" name is because it lets you define macros, which are basically cute lil abbreviations for way longer constructs. it's giving shortcuts, it's giving efficiency πŸ’…

here's the thing though: cpp is meant to be used only with C, C++, and Objective-C source code. in the past people abused her as a general text processor and, no cap, it does not go well 😭 it will choke on input that doesn't obey C's lexical rules. for example, apostrophes get read as the beginning of character constants and just ✨cause errors✨. also you cannot rely on it preserving characteristics of the input that aren't significant to C-family languages. like, if you preprocess a Makefile, all the hard tabs get removed and the Makefile will not work. periodt. πŸ’€

having said all that tho, you can often get away with using cpp on stuff that isn't C πŸ™ˆ other Algol-ish programming languages are usually safe (Ada, etc.), and so is assembly β€” with caution, bestie. -traditional-cpp mode preserves more white space and is otherwise more permissive 🌈 a lot of the problems can be dodged by writing C or C++ style comments instead of native language comments, and by keeping your macros simple. lowkey solid advice.

wherever you possibly can, use a preprocessor made for the language you're actually writing in, fr fr. modern versions of the GNU assembler have macro facilities. most high level programming languages have their own conditional compilation and inclusion mechanism. and if all else fails? go get a true general text processor, like GNU M4 πŸ‘‘

C preprocessors vary in some details, and this manual is about the GNU C preprocessor, which gives you a small superset of the features of ISO Standard C πŸŽ€ in its default mode, GNU CPP skips a few things the standard requires. these are features that are rarely (if ever) used, and they may cause surprising changes to the meaning of a program that doesn't 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. and to get all the mandatory diagnostics you also have to use -pedantic. no skipping steps, bestie.

this manual describes the behavior of the ISO preprocessor πŸ“– and to minimize gratuitous differences, wherever the ISO preprocessor's behavior doesn't 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, every reference to CPP in this manual means 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 into outfile.

either infile or outfile may be -, which as infile means read from standard input, and as outfile means write to standard output 🌈 if either file is omitted, that means the same as if - had been specified for that file. you can also use the -o outfile option to name the output file, if that's more your vibe.

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

⚠️ also!! many options have multi-letter names, which means multiple single-letter options may not be grouped. -dM is very different from -d -M. iykyk πŸ’…

  • -D name β€” predefine name as a macro, with definition 1. easy peasy.
  • -D name=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 is truncated by embedded newline characters.

if you're invoking the preprocessor from a shell or shell-like program, you may need to use the shell's quoting syntax to protect characters β€” like spaces β€” that have a meaning in the shell syntax. protect her 🫢

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 should 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. order matters, bestie!

  • -U name β€” cancel any previous definition of name, whether it was built in or provided with a -D option. un-defining, we love to see it πŸ’…
  • -include file β€” process file as if #include "file" appeared as the first line of the primary source file 🌸 however, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. if it's not found there, it is searched for in the remainder of the #include "..." search chain as normal.

if multiple -include options are given, the files are included in the order they appear on the command line πŸŽ€

  • -imacros file β€” exactly like -include, except that any output produced by scanning file is thrown away πŸ™ˆ macros it defines remain defined though. this lets you acquire all the macros from a header without also processing its declarations. sneaky and genius.

all files specified by -imacros are processed before all files specified by -include ⭐

  • -undef β€” do not predefine any system-specific or GCC-specific macros. the standard predefined macros remain defined, so don't panic πŸ’œ
  • -pthread β€” define additional macros required for using the POSIX threads library 🧡 you should use this option consistently for both compilation and linking, bestie, don't do one and not the other. this option is supported on GNU/Linux targets, most other Unix derivatives, and also on x86 Cygwin and MinGW targets 🌈
  • -M β€” instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file πŸ‘‘ the preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files β€” including those coming from -include or -imacros command-line options. it's giving receipts.

unless specified explicitly (with -MT or -MQ), the object file name consists of the name of the source file with any suffix replaced with the object file suffix, and with any leading directory parts removed ✨ if there are many included files, the rule is split into several lines using \-newline. the rule has no commands.

this option does not suppress the preprocessor's debug output, such as -dM ⚠️ so to avoid mixing such debug output with the dependency rules, you should explicitly specify the dependency output file with -MF, or use an environment variable like DEPENDENCIES_OUTPUT. debug output is still sent to the regular output stream as normal.

passing -M to the driver implies -E, and suppresses warnings with an implicit -w πŸ’…

  • -MM β€” like -M, but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header πŸ™ˆ

this implies that the choice of angle brackets or double quotes in an #include directive does not in itself determine whether that header appears in -MM dependency output. so don't read into the brackets, bestie.

  • -MF file β€” when used with -M or -MM, specifies a file to write the dependencies to πŸ“ if no -MF switch is given, the preprocessor sends the rules to the same place it would send preprocessed output.

when used with the driver options -MD or -MMD, -MF overrides the default dependency output file.

if file is -, then the dependencies are written to stdout ✨

  • -MG β€” in conjunction with an option such as -M requesting dependency generation, -MG assumes missing header files are generated files and adds them to the dependency list without raising an error 🫢 the dependency filename is taken directly from the #include directive without prepending any path. -MG also suppresses preprocessed output, since a missing header file renders this useless.

this feature is used in automatic updating of makefiles πŸŽ€

  • -Mno-modules β€” disable dependency generation for compiled module interfaces 🚫
  • -MP β€” this option instructs CPP to add a phony target for each dependency other than the main file, causing each to depend on nothing 🌈 these dummy rules work around errors make gives you if you remove header files without updating the Makefile to match.

this is typical output:

test.o: test.c test.h

test.h:
  • -MT target β€” change the target of the rule emitted by dependency generation 🎯 by default, CPP takes the name of the main input file, deletes any directory components and any file suffix such as .c, and appends the platform's usual object suffix. the result is the target.

an -MT option sets the target to be exactly the string you specify. if you want multiple targets, you can specify them as a single argument to -MT, or use multiple -MT options. your call, bestie πŸ’…

for example, -MT '$(objpfx)foo.o' might give

$(objpfx)foo.o: foo.c
  • -MQ target β€” same as -MT, but it quotes any characters which are special to Make ✨ so -MQ '$(objpfx)foo.o' gives
$$(objpfx)foo.o: foo.c

the default target is automatically quoted, as if it were given with -MQ πŸ‘‘

  • -MD β€” -MD is equivalent to -M -MF file, except that -E is not implied. the driver determines file based on whether an -o option is given πŸ“ if it is, the driver uses its argument but with a suffix of .d; otherwise it takes the name of the input file, removes any directory components and suffix, and applies a .d suffix.

if -MD is used in conjunction with -E, any -o switch is understood to specify the dependency output file β€” but if used without -E, each -o is understood to specify a target object file 🀯 context is everything.

since -E is not implied, -MD can be used to generate a dependency output file as a side effect of the compilation process. multitasking queen πŸ’…

  • -MMD β€” it's giving -MD but picky: it only mentions user header files, never the system ones. so unserious of the system headers honestly πŸ’…
  • -fpreprocessed β€” bestie, this tells the preprocessor "the input file's already been preprocessed, we're good." it suppresses the whole to-do list: macro expansion, trigraph conversion, escaped newline splicing, and processing of most directives. but it still recognizes and removes comments, so you can pass a file that was preprocessed with -C to the compiler with zero drama 🫢. in this mode the integrated preprocessor is little more than a tokenizer for the front ends.

-fpreprocessed is implicit if the input file has one of the extensions .i, .ii or .mi. these are the extensions that GCC uses for preprocessed files created by -save-temps.

  • -fdirectives-only β€” when preprocessing, handle directives but do not expand macros. its whole personality depends on the -E and -fpreprocessed options.

With -E, preprocessing is limited to the handling of directives such as #define, #ifdef, and #error. other preprocessor operations, such as macro expansion and trigraph conversion, are not performed. also, the -dD option is implicitly enabled. ✨

With -fpreprocessed, predefinition of command line and most builtin macros is disabled. macros such as __LINE__, which are contextually dependent, are handled normally. this enables compilation of files previously preprocessed with -E -fdirectives-only.

With both -E and -fpreprocessed, the rules for -fpreprocessed take precedence. this enables full preprocessing of files previously preprocessed with -E -fdirectives-only.

  • -fdollars-in-identifiers β€” allows $ in identifiers. iconic capitalism-friendly behavior πŸ’°
  • -fextended-identifiers β€” accept universal character names and extended characters in identifiers. enabled by default for C99 (and later C standard versions) and C++. no cap 🧚
  • -fno-canonical-system-headers β€” when preprocessing, do not shorten system header paths with canonicalization. live your truth, long paths πŸ“
  • -fmax-include-depth=depth β€” sets the maximum depth of the nested #include. default is 200. don't go nesting infinitely, that's giving infinite recursion energy πŸ’€
  • -ftabstop=width β€” sets the distance between tab stops. this helps the preprocessor report correct column numbers in warnings or errors, even when tabs show up on the line. if the value is less than 1 or greater than 100, the option is ignored (yes bestie, silently). default is 8.
  • -ftrack-macro-expansion[=level] β€” tracks locations of tokens across macro expansions. this lets the compiler emit diagnostics about the current macro expansion stack when a compilation error happens inside a macro expansion. using this option makes the preprocessor and the compiler eat more memory 😭. the level parameter picks how precise the token location tracking is, which can lower the memory consumption if you need it:
    • value 0 of level de-activates this option
    • value 1 tracks token locations in a degraded mode for the sake of minimal memory overhead β€” in this mode all tokens resulting from the expansion of an argument of a function-like macro have the same location
    • value 2 tracks token locations completely β€” the most memory hungry one πŸ“

When this option is given no argument, the default parameter value is 2.

Note that -ftrack-macro-expansion=2 is activated by default. yeah. it's on. surprise πŸ’…
  • -fmacro-prefix-map=old=new β€” when preprocessing files residing in directory old, expand the __FILE__ and __BASE_FILE__ macros as if the files resided in directory new instead. you can use this to change an absolute path to a relative path by using . for new, which can result in more reproducible builds that are location independent 🌈. this option also affects __builtin_FILE() during compilation. see also -ffile-prefix-map and -fcanon-prefix-map.
  • -fexec-charset=charset β€” sets the execution character set, used for string and character constants. default is UTF-8. charset can be any encoding supported by the system's iconv library routine.
  • -fwide-exec-charset=charset β€” sets the wide execution character set, used for wide string and character constants. the default is one of UTF-32BE, UTF-32LE, UTF-16BE, or UTF-16LE, whichever corresponds to the width of wchar_t and the big-endian or little-endian byte order being used for code generation. just like -fexec-charset, charset can be any encoding supported by the system's iconv library routine β€” however, you'll have problems with encodings that don't fit exactly in wchar_t πŸ™ˆ
  • -finput-charset=charset β€” sets the input character set, used for translation from the character set of the input file to the source character set used by GCC. if the locale doesn't specify it, or if GCC can't get this info from the locale, the default is UTF-8. this can be overridden by either the locale or by this command-line option. currently the command-line option takes precedence if there's a conflict. charset can be any encoding supported by the system's iconv library routine.
  • -fworking-directory β€” enables generation of linemarkers in the preprocessor output so the compiler knows the current working directory at the time of preprocessing. when this is enabled, the preprocessor emits, after the initial linemarker, a second linemarker with the current working directory followed by two slashes. GCC uses this directory, when it's 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 can be inhibited with the negated form -fno-working-directory. if the -P flag is present on the command line, this option has no effect, since no #line directives are emitted whatsoever. periodt βœ‹
  • -A predicate=answer β€” make an assertion with the predicate predicate and answer answer. this form is preferred over the older form -A predicate(answer) β€” which is still supported btw β€” because it doesn't use shell special characters. she's practical πŸ’…
  • -A -predicate=answer β€” cancel an assertion with the predicate predicate and answer answer. yeah, the - in -predicate is the whole move here, iconic.
  • -C β€” do not discard comments. all comments get 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 bestie 😭 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 #.
  • -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.

on top of 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 a 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.

  • -P β€” inhibit generation of linemarkers in the output from the preprocessor. this might be useful when running the preprocessor on something that isn't C code, and it'll be sent to a program which might be confused by the linemarkers. not every program speaks linemarker, respect that 🌸
  • -traditional, -traditional-cpp β€” try to imitate the behavior of pre-standard C preprocessors, as opposed to ISO C preprocessors. she's vintage, she's nostalgic πŸŽ€
note that GCC does not otherwise attempt to emulate a pre-standard C compiler, and these options are only supported with the -E switch, or when invoking CPP explicitly.
  • -trigraphs β€” support ISO C trigraphs. these are three-character sequences, all starting with ??, that are defined by ISO C to stand for single characters. for example, ??/ stands for \, so '??/n' is a character constant for a newline. by default, GCC ignores trigraphs, but in standard-conforming modes it converts them. see the -std and -ansi options. ?? gang rise up πŸ¦‹
  • -remap β€” enable special code to work around file systems which only permit very short file names, such as MS-DOS. retro 8.3 energy, we respect the elders πŸ‘‘
  • -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. precompiled header files are also printed, even if they're found to be invalid; an invalid precompiled header file is printed with ...x and a valid one with ...!. so you always know which one's the flop and which one's the slay πŸ“
  • -dletters β€” says to make debugging dumps during compilation as specified by letters. the flags documented here are those relevant to the preprocessor. other letters are interpreted by the compiler proper, or reserved for future versions of GCC, and so are silently ignored 🀫. if you specify letters whose behavior conflicts, the result is undefined.
    • -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.h, the command
touch foo.h; cpp -dM foo.h

shows all the predefined macros.

  • -dD β€” like -dM except that it outputs both the #define directives and the result of preprocessing. both kinds of output go to the standard output file. double the content, double the fun πŸ’…
  • -dN β€” like -dD, but emit only the macro names, not their expansions.
  • -dI β€” output #include directives in addition to the result of preprocessing.
  • -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. she's patient and specific πŸŽ€
  • -fdebug-cpp β€” this option is only useful for debugging GCC. when used from CPP or with -E, it dumps debugging information about location maps. every token in the output is preceded by the dump of the map its location belongs to.

when used from GCC without -E, this option has no effect. cute but powerless in that context πŸ™ˆ

  • -I dir, -iquote dir, -isystem dir, -idirafter dir β€” add the directory dir to the list of directories to be searched for header files during preprocessing.

If dir starts with = or $SYSROOT, bestie, then that little = or $SYSROOT gets swapped out for the sysroot prefix β€” go peek at --sysroot and -isysroot for the deets. πŸ’«

Directories you name with -iquote are only for the quote form of the directive, aka #include "file". But dirs you name with -I, -isystem, or -idirafter? Those show up for both #include "file" and #include <file>. Both. Equal opportunity. πŸ‘‘

You can stack up any number or any combo of these options on the command line to hunt through a whole bunch of directories, and the lookup order is literally this:

  1. For the quote form of the include directive, the directory of the current file gets searched first. Home turf first, always. 🏠
  2. For the quote form, the directories given by -iquote get searched left-to-right, exactly how they showed up on the command line.
  3. Directories from -I get scanned left-to-right.
  4. Directories from -isystem get scanned left-to-right.
  5. Standard system directories get scanned.
  6. Directories from -idirafter get scanned left-to-right.

You can use -I to override a system header file and sub in your own version, because these directories get searched before the standard system header directories. Slay. ✨

But bestie β€” do not use this option to add directories that hold vendor-supplied system header files. That's what -isystem is for. Different tool, different vibe. πŸ’…

The -isystem and -idirafter options also mark the directory as a system directory, so it gets the exact same special treatment the standard system directories get. Fancy. πŸŽ€

Here's a lil gotcha: if a standard system include directory (or a directory you gave with -isystem) is also given with -I, the -I option gets ignored. The directory is still searched, but as a system directory at its normal position in the system include chain. Why? Because GCC's whole procedure for fixing buggy system headers, plus the ordering for the #include_next directive, must not get inadvertently changed. So if you really need to change the search order for system directories, use -nostdinc and/or -isystem. That's the move. 🫢

  • -I- β€” split the include path. ⚠️ This option has been deprecated. Please use -iquote instead for the -I directories before the -I-, and just remove the -I- option entirely.

Any directories given with -I options before the -I- get searched only for headers requested with #include "file" β€” they are not searched for #include <file>. But if you add more directories with -I options after the -I-, those get searched for all #include directives.

On top of that, -I- inhibits the use of the current file's directory as the first search directory for #include "file". And there is no way to override this effect of -I-. It's giving final boss energy. πŸ’€

  • -iprefix prefix β€” set prefix as the prefix for subsequent -iwithprefix options. If the prefix represents a directory, you should include the final /. Don't forget it, bestie. πŸ™ˆ
  • -iwithprefix dir β€” and -iwithprefixbefore dir β€” append dir to the prefix you set earlier with -iprefix, then add the resulting directory to the include search path. -iwithprefixbefore puts it in the same place -I would; -iwithprefix puts it where -idirafter would. Same dir, different seat at the table. πŸ’œ
  • -isysroot dir β€” this is like the --sysroot option, but it applies only to header files β€” except for Darwin targets, where it applies to both header files and libraries. See the --sysroot option for more info. πŸ¦‹
  • -imultilib dir β€” use dir as a subdirectory of the directory containing target-specific C++ headers. Nesting doll situation. πŸŽ€
  • -nostdinc β€” do not search the standard system directories for header files. Only the directories you explicitly named with -I, -iquote, -isystem, and/or -idirafter options get searched β€” plus the directory of the current file, if that's appropriate. You're on your own now. ✨
  • -nostdinc++ β€” don't search for header files in the C++-specific standard directories, but do still search the other standard directories. (This option is used when building the C++ library.) Very niche, very iconic. πŸ‘‘
  • -Wcomment and -Wcomments β€” warn whenever a comment-start sequence /* appears in a /* comment, or whenever a backslash-newline appears in a // comment. This warning is enabled by -Wall. 😭
  • -Wtrigraphs β€” warn if any trigraphs are encountered that might change the meaning of the program. Trigraphs within comments are not warned about, except those that would form escaped newlines.

This option is implied by -Wall. If -Wall isn't given, it's still enabled unless trigraphs are enabled. And if you want trigraph conversion without warnings, but you do want the other -Wall warnings? Then use -trigraphs -Wall -Wno-trigraphs. There's your combo meal. πŸ“

  • -Wundef β€” warn if an undefined identifier gets evaluated in an #if directive. Those identifiers get replaced with zero. Zero. Nothing. Void. πŸ’€
  • -Wexpansion-to-defined β€” warn whenever defined is encountered in the expansion of a macro (including when the macro is expanded by an #if directive). Such usage is not portable. Not portable! This warning is also enabled by -Wpedantic and -Wextra.
  • -Wunused-macros β€” warn about macros defined in the main file that go unused. A macro counts as used if it's expanded or tested for existence at least once. The preprocessor also warns if the macro hasn't been used by the time it gets redefined or undefined.

Built-in macros, macros defined on the command line, and macros defined in include files are not warned about. They're exempt. VIP section. πŸ’…

Note, bestie: if a macro is actually used, but only used inside skipped conditional blocks, the preprocessor reports it as unused anyway. To dodge the warning in that case, you might improve the scope of the macro's definition by, like, moving it into the first skipped block. Or alternatively you could provide a dummy use with something like:
#if defined the_macro_causing_the_warning
#endif
  • -Wno-endif-labels β€” don't warn whenever an #else or an #endif are followed by text. This sometimes happens in older programs with code of the form:
#if FOO
...
#else FOO
...
#endif FOO

The second and third FOO should be in comments. This warning is on by default. Careful out there. πŸ™ˆ


🌸 ENVIRONMENT 🌸

This section is all about the environment variables that affect how CPP operates, bestie. 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 like -I, and control dependency output with options like -M. Those take precedence over environment variables β€” and environment variables in turn take precedence over the configuration of GCC. It's a whole hierarchy. Respect the chain. πŸ‘‘

  • CPATH
  • C_INCLUDE_PATH
  • CPLUS_INCLUDE_PATH
  • OBJC_INCLUDE_PATH

Each variable's value is a list of directories separated by a special character, much like PATH, in which to look for header files. That special character, PATH_SEPARATOR, is target-dependent and figured out at GCC build time. For Microsoft Windows-based targets it's a semicolon, and for almost all other targets it's a colon.

CPATH specifies a list of directories to be searched as if they were specified with -I β€” but after any paths given with -I options on the command line. This environment variable gets used regardless of which language is being preprocessed. It doesn't pick favourites. ✨

The remaining environment variables apply only when preprocessing the particular language indicated. Each one specifies a list of directories to be searched as if specified with -isystem, but after any paths given with -isystem options on the command line.

And in all these variables, an empty element tells the compiler to search its current working directory. Empty elements can show up at the beginning or the end of a path. For instance, if the value of CPATH is :/special/include, that has the same effect as -I. -I/special/include. Sneaky lil empty string. πŸ›

  • DEPENDENCIES_OUTPUT β€” if this variable is set, its value specifies how to output dependencies for Make based on the non-system header files processed by the compiler. System header files get ignored in the dependency output. Not invited to the party. πŸ™…β€β™€οΈ

The value of DEPENDENCIES_OUTPUT can be just a file name, in which case the Make rules get written to that file, guessing the target name from the source file name. Or the value can have the form file target, in which case the rules get written to file file using target as the target name.

In other words? This environment variable is equivalent to combining the options -MM and -MF, with an optional -MT switch too. Two-for-one. πŸŽ€

  • SUNPRO_DEPENDENCIES β€” this variable is the same as DEPENDENCIES_OUTPUT (see above), except that system header files are not ignored, so it implies -M rather than -MM. However, the dependence on the main input file is omitted. Close cousin, slightly different rules. πŸ’œ
  • SOURCE_DATE_EPOCH β€” if this variable is set, its value 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. Reproducible builds are so iconic. 🌈

The value of SOURCE_DATE_EPOCH must be a UNIX timestamp, defined as the number of seconds (excluding leap seconds) since 01 Jan 1970 00:00:00 represented in ASCII β€” identical to the output of date +%s on GNU/Linux and other systems that support the %s extension in the date command.

The value should be a known timestamp, such as the last modification time of the source or package, and it should be set by the build process. Don't just make one up. 😌


πŸ‘€ SEE ALSO πŸ‘€


Copyright (c) 1987-2024 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.

and that's a wrap on CPP(1), bestie!! 🫢✨ this page is from the gcc-14 crew, dated 2026-09-02, and honestly? iconic of them. now go write some beautiful preprocessor code, and remember: the vibe changes, but the facts never do. mwah. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from