msgcpp - C language message catalog preprocessor


msgcpp [ options ] [ input [ output ] ]


msgcpp is a C language message catalog preprocessor. It accepts cpp(1) style options and arguments. msgcpp preprocesses an input C source file and emits keyed lines to the output, usually for further processing by msgcc(1). msgcc output is in the gencat(1) syntax. Candidate message text is determined by arguments to the ast <error.h> and <option.h> functions. The msgcpp keyed output lines are:
cmd command

command is a candidate for --??keys option string generation. Triggered by b_command(int argc, in the input.
def name string

name is a candidate variable with string value string .
str string

string should be entered into the catalog.
var name

If def name occurs then its string value should be entered into the catalog.

The input source file is preprocessed with the pp:allpossible option on. This enables non-C semantics; all source should first be compiled error-free with a real compiler before running msgcpp. The following changes are enabled for the top level files (i.e., included file behavior is not affected):
All #if, #ifdef and #ifndef branches are enabled.
The first definition for a macro is retained, even when subsequent #define statements would normally redefine the macro. #undef must be used to redefine a macro.
Macro calls with an improper number of arguments are silently ignored.
#include on non-existent headers are silently ignored.
Invalid C source characters are silently ignored.

"msgcat.h" is included if it exists. This file may contain macro definitions for functions that translate string arguments. If foo is a function that translates its string arguments then include the line #define foo _TRANSLATE_ in msgcat.h or specify the option -Dfoo=_TRANSLATE_. If bar is a function that translates string arguments if the first argument is stderr then use either #define bar _STDIO_ or -Dbar=_STDIO_ .

The macro _BLD_msgcat is defined to be 1. As an alternative to msgcat.h, _TRANSLATE_ definitions could be placed inside #ifdef _BLD_msgcat ... #endif.


cc(1), cpp(1), gencat(1), msggen(1), msgcc(1), msgcvt(1)



msgcpp (AT&T Research) 2002-03-11

Glenn Fowler <>

Copyright © 2000-2012 AT&T Intellectual Property


cpp - C language preprocessor


cpp is the preprocessor for all C language dialects. It is a standalone version of the libpp(3) preprocessor library. The C dialect implemented by cpp is determined by probing cc(1) using probe(1). The path of the emulated compiler can be changed by the -D-X command line option.

If output is omitted then the standard output is written; if input is also omitted then the standard input is read. NOTE: this is an ancient, non-standard, non-intuitiive file operand syntax that is required by cc(1); use shell file name expansion at your peril.

cpp specific options are set by the -D- and -I- options.


-C, --comments

Pass comments to the output. By default comments are omitted.
-D, --define=name[=value]

Define the macro name to have value; 1 is assumed if = value is omitted. If name begins with : then it is interpreted as a libpp(3) #pragma pp: statement; if name begins with % then it is interpreted as a libpp(3) # directive statement; if name begins with - or + then it is interpreted as a libpp(3) option; - turns the option on, + turns it off. Most options have a #pragma counterpart that is listed with the option definition. Right, this is ugly, but its the only portable way to pass options through cc(1) to cpp:
-D-C, pp:compatibility

Preprocess for K&R compatibility.
-D-Dlevel, pp:debug level

Set the debug trace level. Higher levels produce more output. Levels higher than 3 enabled only in -g compiled versions.

Set the main input file name to name. This only affects error message and line sync output.
-D-H, pp:hosted

All directories are hosted; compatibility warning messages from hosted directory headers are suppressed.
-D-I, pp:cdir

All directories contain C headers; used only with -D-+.
-D-K, pp:keyargs

Enable the non-standard name=value macro argument mode.
-D-L[id], pp:lineid [id]

Set the line sync directive id to id or null if omitted.
-D-M, pp:nomultiple

Disable multiple include detection.
-D-P, pp:passthrough

Enable the non-standard passthrough mode; may be useful for processing non-C input.
-D-Q, pp:dump

Dump macro definitions to the output so that the output may be passed through cpp again. Used for generating precompiled headers.
-D-R, pp:transition

Enable the transition preprocessing mode. Used for compilers that can't make up their semantics between K&R and ISO.
-D-S, pp:strict

Enable strict preprocessing semantics and warnings. Works with any mode (compatibiliy, transition, or the default ISO).
-D-Ttest, pp:test test

Enable implementation specific test code according to test.
-D-W, pp:warn

Enable warnings in non-hosted files.

Preprocess for the compiler cc which must be an executable path or an executable on $PATH.
-D-Y, pp:pedantic

Enable pedantic pp::warn warnings in non-hosted files.
-D-Z, pp:pool

Enable pool mode. See libpp(3).
List canonicalized #define statements for non-predefined macros in the output.
List canonicalized #define statements for all macros. All other output is disabled.
-D-+, pp:plusplus

Preprocess for the C++ dialect.
-I, --include[=directory]

Append directory to the list of directories searched for #include files. If directory is - then: (1) -I directories before -I- are searched only for "..." include files; (2) -I directories after -I- are searched for "..." and <...> include files; (3) the directory . is searched only if it is explicitly specified by a -I option.
-I-Cdirectory, pp:cdir directory

Mark directory as a C header directory. Used with pp:plusplus.

Read the default probe(1) definitions from file, or ignore the default definitions if file is omitted.
-I-Hdirectory, pp:hostdir directory

Mark directory as a hosted directory. Headers from hosted directories have compatibility warnings disabled.
-I-Iheader, pp:ignore header

Add header to the list of ignored headers.

file contains a sequence of header [= "map" ] lines, where header is either <name> or "name", and "map" is an explicit binding for header. header is ignored if = "map" is omitted.

Include file but do not emit text or line syncs.

Add directory to the default standard include directory list.

Include file and emit text to the output file.
The option value may be omitted.
-M, --dependencies

Generate make(1) dependencies. Not needed with nmake(1). -M may be followed by optional flags to change dependency output styles:
Generate dependencies in a separate .d file. Preprocessed output is still written to output , or the standard output if output is omitted.
Generate missing dependencies too.
Only generate local header dependencies; hosted headers are omitted. Note that hosted headers are determined by -I-H and the pp:hosted and pp:hostdir pragmas; no special distiction is made between "" and <> include styles.
-P, --sync

Emit line syncs. On by default; -P means --nosync.
-U, --undefine=name

Remove the definition for the macro name.
-A, --assert=assertion

Enter the assertion via #assert for system V compatibility.
-E, --preprocess

Ignored for compatibility with ancient compilers.
-H, --include-reference[=size]

Emit #include file paths on the standard error, one per line, indented to show nesting. If the optional size argument is specified then the entire -H option is ignored. The option value may be omitted.

If not gcc(1) then truncate identifiers to length characters for compatibility with old AT&T (I guess only Lucent needs them now) compilers. The option value may be omitted.
-V, --version

Emit the libpp(3) version.
-X, --argmode

Enable name=value macro arguments for easel(1) compatibility.
-Y, --standard=directory

Add directory to the list searched for #include <...> files.


cc(1), gcc(1), libpp(3)



cpp (AT&T Research) 2009-02-02

Glenn Fowler <>

Copyright © 1986-2012 AT&T Intellectual Property