2 .\" Copyright (c) 1986-2006 AT&T Knowledge Ventures
3 .\" To view license terms, see http://www.opensource.org/licenses/cpl1.0.txt
4 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc.
5 .TH MSGCPP 1 "Oct 9, 2007"
7 msgcpp \- C language message catalog preprocessor
11 \fBmsgcpp\fR [\fB-ACEHMPVX\fR] [\fB-D\fR \fIname\fR[\fB=\fR\fIvalue\fR]] [\fB-I\fR \fIdirectory\fR] [\fB-U\fR \fIname\fR]
12 [\fB-T\fR[\fIlength\fR]] [\fB-Y\fR \fIdirectory\fR] [\fIinput\fR [\fIoutput\fR] ]
18 \fBmsgcpp\fR is a C language message catalog preprocessor. It accepts
19 \fBcpp\fR(1) style options and arguments. \fBmsgcpp\fR preprocesses an input C
20 source file and emits keyed lines to the output, usually for further processing
21 by\fBmsgcc\fR(1). \fBmsgcc\fR output is in the \fBgencat\fR(1) syntax.
22 Candidate message text is determined by arguments to the last \fB<error.h>\fR
23 and \fB<option.h>\fR functions. The \fBmsgcpp\fR keyed output lines are:
27 \fB\fBcmd\fR \fIcommand\fR\fR
30 \fIcommand\fR is a candidate for \fB--??keys\fR option string generation. This
31 is triggered by \fBb_command(int argc\fR, in the input.
37 \fB\fBdef\fR \fIname string\fR\fR
40 \fIname\fR is a candidate variable with \fIstring\fR value string.
46 \fB\fBstr\fR \fIstring\fR\fR
49 \fIstring\fR should be entered into the catalog.
55 \fB\fBvar\fR \fIname\fR\fR
58 If \fBdef\fR \fIname\fR occurs then its string value should be entered into the
64 The input source file is preprocessed with the \fBpp:allpossible\fR option on.
65 This enables non-C semantics. All source should first be compiled error-free
66 with a real compiler before running \fBmsgcpp\fR. The following changes are
67 enabled for the top level files. Included file behavior is not affected.
71 All \fB#if\fR, \fB#ifdef\fR and \fB#ifndef\fR branches are enabled.
76 The first definition for a macro is retained, even when subsequent
77 \fB#define\fR statements would normally redefine the macro. \fB#undef\fR must
78 be used to redefine a macro.
83 Macro calls with an improper number of arguments are silently ignored.
88 \fB#include\fR on non-existent headers are silently ignored.
93 Invalid C source characters are silently ignored.
97 \fBmsgcat.h\fR is included if it exists. This file may contain macro
98 definitions for functions that translate string arguments. If \fBfoo\fR is a
99 function that translates its string arguments then include the line \fB#define
100 foo _TRANSLATE_\fR in \fBmsgcat.h\fR, or specify the option
101 \fB-Dfoo=_TRANSLATE_\fR. If \fBbar\fR is a function that translates string
102 arguments if the first argument is \fBstderr\fR, then use either \fB#define bar
103 _STDIO_\fR or \fB-Dbar=_STDIO_\fR.
106 The macro \fB_BLD_msgcat\fR is defined to be \fB1\fR. As an alternative to
107 \fBmsgcat.h\fR, \fB_TRANSLATE_\fR definitions could be placed inside \fB#ifdef
108 _BLD_msgcat ... #endif\fR.
112 The following options are supported:
120 \fB\fB--assert=\fR\fIassertion\fR\fR
123 Enter the assertion using \fB#assert\fR for system V compatibility.
133 \fB\fB--comments\fR\fR
136 Pass comments to the output.
138 Comments are omitted by default.
148 \fB\fB--define=\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]\fR\fR
151 Define the macro \fIname\fR to have \fIvalue\fR. This is the only portable way
152 to pass options through \fBcc\fR to \fBcpp\fR(1).
157 If \fB=\fR\fIvalue\fR is omitted, \fIvalue\fR is assumed to be \fB1\fR .
163 If \fIname\fR begins with \fB:\fR, then it is interpreted as a \fBlibpp\fR
164 \fB#pragma pp\fR: statement.
170 If \fIname\fR begins with \fB%\fR, it is interpreted as a \fBlibpp\fR \fB#\fR
177 If name begins with a \fB-\fR or a \fB+\fR, it is interpreted as a \fBlibpp\fR
180 \fB-\fR turns the option on, \fB+\fR turns it off.
186 Most options have a \fB#pragma\fR counterpart that is listed with the option
196 \fB\fBpp:compatibility\fR\fR
200 Preprocess for K&R C compatibility.
206 \fB\fB-D-D\fR\fIlevel\fR\fR
210 \fB\fBpp:debug level\fR \fIlevel\fR\fR
214 Set the debug trace level.
216 Specify \fIlevel\fR as a number greater than or equal to \fB0\fR. Higher levels
217 produce more output. Levels higher than \fB3\fR can only be enabled in the
218 \fB-g\fR compiled versions.
224 \fB\fB-D-F\fR\fIname\fR\fR
228 Set the main input file name to \fIname\fR. This only affects the error
229 messages and the line sync output.
239 \fB\fBpp:hosted\fR\fR
243 All directories are hosted. Compatibility warning messages from the hosted
244 directory headers are suppressed.
258 All directories contain C headers. This option is only used only with
269 \fB\fBpp:keyargs\fR\fR
273 Enable the non-standard \fIname\fR\fB=\fR\fIvalue\fR macro argument mode.
279 \fB\fB-D-L\fR\fB[\fR\fIid\fR\fB]\fR\fR
283 \fB\fBpp:lineid [\fR\fIid\fR]\fR
287 Set the line sync directive id to \fIid\fR. If \fIid\fR is not specified, set
298 \fB\fBpp:nomultiple\fR\fR
302 Disable multiple include detection.
312 \fB\fBpp:passthrough\fR\fR
316 Enable the non-standard passthrough mode. This can be useful for processing
331 Dump macro definitions to the output so that the output may be passed through
332 \fBcpp\fR again. This is used for generating precompiled headers.
342 \fB\fBpp:transition\fR\fR
346 Enable the transition preprocessing mode. This is used for compilers that
347 cannot make up their semantics between K&R and ISO C.
357 \fB\fBpp:strict\fR\fR
361 Enable strict preprocessing semantics and warnings. This works with any mode
362 (compatibility, transition, or the default ISO).
368 \fB\fB-D-T\fR\fItest\fR\fR
372 \fB\fBpp:test\fR \fItest\fR\fR
376 Enable implementation specific test code according to \fItest\fR.
390 Enable pedantic warnings in non-hosted files.
396 \fB\fB-D-X\fR\fB[cc]\fR\fR
404 Preprocess for the \fBcc\fR compiler, which must be an executable path or an
405 executable on \fB$PATH\fR.
429 List canonicalized \fB#define\fR statements for non-predefined macros in the
440 List canonicalized \fB#define\fR statements for all macros. All other output is
451 \fB\fBpp:plusplus\fR\fR
455 Preprocess for the C++ dialect.
467 \fB\fB--preprocess\fR\fR
470 Ignored; for compatibility with very old compilers.
480 \fB\fB--include-reference\fR\fR
483 Emit \fB#include\fR file paths on the standard error, one per line, indented to
494 \fB\fB--include[=\fR\fIdirectory\fR\fB]\fR\fR
497 Append directory to the list of directories searched for \fB#include\fR files.
499 If directory is \fB-\fR:
503 \fB-I\fR directories before \fB-I-\fR are searched only for \fB"..."\fR
509 \fB-I\fR directories after \fB-I-\fR are searched for \fB"..."\fR and
510 \fB<"...">\fR include files
515 the directory \fB\&.\fR is searched only if it is explicitly specified by an
521 \fB\fB-I-C\fR\fIdirectory\fR\fR
525 \fB\fBpp:cdir directory\fR\fR
529 Mark \fIdirectory\fR as a C header directory. This option is used with
536 \fB\fB-I-D[\fR\fIfile\fR]\fR
540 Read the default \fBprobe\fR definitions from \fIfile\fR, or ignore the default
541 definitions if \fIfile\fR is omitted.
547 \fB\fB-I-H\fR\fIdirectory\fR\fR
551 \fB\fBpp:hostdir\fR \fIdirectory\fR\fR
555 Mark directory as a hosted directory. Headers from hosted directories have
556 compatibility warnings disabled.
562 \fB\fB-I-I\fR\fIheader\fR\fR
566 \fB\fBpp:ignore\fR \fIheader\fR\fR
570 Add \fIheader\fR to the list of ignored headers.
576 \fB\fB-I-M\fR\fIfile\fR\fR
580 \fIfile\fR contains a sequence of header \fB[= "map" ]\fR lines, where header
581 is either \fB<name>\fR or \fB"name"\fR, and \fB"map"\fR is an explicit binding
582 for header. header is ignored \fBif = "map"\fR is omitted.
588 \fB\fB-I-R\fR\fIfile\fR\fR
592 Include \fIfile\fR but do not emit text or line syncs.
598 \fB\fB-I-S\fR\fIdirectory\fR\fR
602 Add \fIdirectory\fR to the default standard include directory list.
608 \fB\fB-I-T\fR\fIfile\fR\fR
612 Include \fIfile\fR and emit text to the output file. The option value can be
625 \fB\fB--dependencies\fR\fR
628 Generate \fBmake\fR(1S) dependencies. This option is not needed with
631 The \fB-M\fR option can be followed by optional flags to change the dependency
634 The following optional flags are supported:
641 Generate dependencies in a separate \fB\&.d\fR file. Preprocessed output is
642 still written to output, or the standard output if output is omitted.
651 Also generate missing dependencies.
660 Only generate local header dependencies. Hosted headers are omitted. Hosted
661 headers are determined by the \fB-I-H\fR option and the -\fB-pp:hosted\fR and
662 \fBpp:hostdir pragmas\fR. No special distinction is made between the \fB""\fR
663 and \fB<>\fR include styles.
680 Line sync is turned on by default. \fB-P\fR means \fB--nosync\fR.
686 \fB\fB-T\fR\fB[\fR\fIlength\fR\fB]\fR\fR
689 If not \fBgcc\fR, truncate identifiers to \fIlength\fR characters for
690 compatibility with old AT&T compilers.
700 \fB\fB--undefine=\fR\fIname\fR\fR
703 Remove the definition for the macro \fIname\fR.
713 \fB\fB--version\fR\fR
716 Emit the \fBlibpp\fR version.
726 \fB\fB--argmode\fR\fR
729 Enable \fIname\fR\fB=\fR\fIvalue\fR macro arguments for \fBeasel\fR
740 \fB\fB--standard=\fR\fIdirectory\fR\fR
743 Add \fIdirectory\fR to the list searched for \fB#include <...>\fR files.
749 The following operands are supported:
756 Specifies C source file to preprocess.
765 Specifies output file.
775 Successful completion.
789 \fBExample 1 \fRUsing \fBmsgcpp\fR to Extract Localizable Strings
792 The following example uses \fBmsgcpp\fR to extract localizable strings from the
793 file \fBhello.c\fR, marked using the \fBERROR_dictionary()\fR, and writes them
794 to the file \fBhello.mso\fR:
806 * dummy macro to avoid including
809 #define ERROR_dictionary(x) x
811 int main(int ac, char *av[])
813 puts( ERROR_dictionary("hello world") );
814 puts( ERROR_dictionary("hello all") );
815 return( EXIT_SUCCESS );
818 example% msgcpp -D__STDC__ -D__i386 hello.c hello.mso
820 example% cat hello.mso
830 Glenn Fowler, \fBgsf@research.att.com\fR
834 See \fBattributes\fR(5) for descriptions of the following attributes:
842 ATTRIBUTE TYPE ATTRIBUTE VALUE
844 Interface Stability Volatile
850 \fBcpp\fR(1), \fBgencat\fR(1), \fBmsgcc\fR(1), \fBmsgcvt\fR(1),
851 \fBmsggen\fR(1), \fBmake\fR(1S), \fBattributes\fR(5)
854 Kernighan, Brian W. and Ritchie, Dennis M., \fIThe C Programming Language\fR,