Merge commit 'b31ca922c7346747131aed07c0c171ec2f573aac' into merges
[unleashed.git] / share / man / man1 / msgcpp.1
blob7627b912a614ec265da1222abadf8916e5fdf247
1 '\" te
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"
6 .SH NAME
7 msgcpp \- C language message catalog preprocessor
8 .SH SYNOPSIS
9 .LP
10 .nf
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] ]
13 .fi
15 .SH DESCRIPTION
16 .sp
17 .LP
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:
24 .sp
25 .ne 2
26 .na
27 \fB\fBcmd\fR \fIcommand\fR\fR
28 .ad
29 .RS 19n
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.
32 .RE
34 .sp
35 .ne 2
36 .na
37 \fB\fBdef\fR \fIname string\fR\fR
38 .ad
39 .RS 19n
40 \fIname\fR is a candidate variable with \fIstring\fR value string.
41 .RE
43 .sp
44 .ne 2
45 .na
46 \fB\fBstr\fR \fIstring\fR\fR
47 .ad
48 .RS 19n
49 \fIstring\fR should be entered into the catalog.
50 .RE
52 .sp
53 .ne 2
54 .na
55 \fB\fBvar\fR \fIname\fR\fR
56 .ad
57 .RS 19n
58 If \fBdef\fR \fIname\fR occurs then its string value should be entered into the
59 catalog.
60 .RE
62 .sp
63 .LP
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.
68 .RS +4
69 .TP
71 All \fB#if\fR, \fB#ifdef\fR and \fB#ifndef\fR branches are enabled.
72 .RE
73 .RS +4
74 .TP
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.
79 .RE
80 .RS +4
81 .TP
83 Macro calls with an improper number of arguments are silently ignored.
84 .RE
85 .RS +4
86 .TP
88 \fB#include\fR on non-existent headers are silently ignored.
89 .RE
90 .RS +4
91 .TP
93 Invalid C source characters are silently ignored.
94 .RE
95 .sp
96 .LP
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.
109 .SH OPTIONS
112 The following options are supported:
114 .ne 2
116 \fB\fB-A\fR\fR
120 \fB\fB--assert=\fR\fIassertion\fR\fR
122 .RS 25n
123 Enter the assertion using \fB#assert\fR for system V compatibility.
127 .ne 2
129 \fB\fB-C\fR\fR
133 \fB\fB--comments\fR\fR
135 .RS 25n
136 Pass comments to the output.
138 Comments are omitted by default.
142 .ne 2
144 \fB\fB-D\fR\fR
148 \fB\fB--define=\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]\fR\fR
150 .RS 25n
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).
153 .RS +4
155 .ie t \(bu
156 .el o
157 If \fB=\fR\fIvalue\fR is omitted, \fIvalue\fR is assumed to be \fB1\fR .
159 .RS +4
161 .ie t \(bu
162 .el o
163 If \fIname\fR begins with \fB:\fR, then it is interpreted as a \fBlibpp\fR
164 \fB#pragma pp\fR: statement.
166 .RS +4
168 .ie t \(bu
169 .el o
170 If \fIname\fR begins with \fB%\fR, it is interpreted as a \fBlibpp\fR \fB#\fR
171 directive statement.
173 .RS +4
175 .ie t \(bu
176 .el o
177 If name begins with a \fB-\fR or a \fB+\fR, it is interpreted as a \fBlibpp\fR
178 option.
180 \fB-\fR turns the option on, \fB+\fR turns it off.
182 .RS +4
184 .ie t \(bu
185 .el o
186 Most options have a \fB#pragma\fR counterpart that is listed with the option
187 definition.
190 .ne 2
192 \fB\fB-D-C\fR\fR
196 \fB\fBpp:compatibility\fR\fR
198 .sp .6
199 .RS 4n
200 Preprocess for K&R C compatibility.
204 .ne 2
206 \fB\fB-D-D\fR\fIlevel\fR\fR
210 \fB\fBpp:debug level\fR \fIlevel\fR\fR
212 .sp .6
213 .RS 4n
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.
222 .ne 2
224 \fB\fB-D-F\fR\fIname\fR\fR
226 .sp .6
227 .RS 4n
228 Set the main input file name to \fIname\fR. This only affects the error
229 messages and the line sync output.
233 .ne 2
235 \fB\fB-D-H\fR\fR
239 \fB\fBpp:hosted\fR\fR
241 .sp .6
242 .RS 4n
243 All directories are hosted. Compatibility warning messages from the hosted
244 directory headers are suppressed.
248 .ne 2
250 \fB\fB-D-I\fR\fR
254 \fB\fBpp:cdir\fR\fR
256 .sp .6
257 .RS 4n
258 All directories contain C headers. This option is only used only with
259 \fB-D-+\fR.
263 .ne 2
265 \fB\fB-D-K\fR\fR
269 \fB\fBpp:keyargs\fR\fR
271 .sp .6
272 .RS 4n
273 Enable the non-standard \fIname\fR\fB=\fR\fIvalue\fR macro argument mode.
277 .ne 2
279 \fB\fB-D-L\fR\fB[\fR\fIid\fR\fB]\fR\fR
283 \fB\fBpp:lineid [\fR\fIid\fR]\fR
285 .sp .6
286 .RS 4n
287 Set the line sync directive id to \fIid\fR. If \fIid\fR is not specified, set
288 to null.
292 .ne 2
294 \fB\fB-D-M\fR\fR
298 \fB\fBpp:nomultiple\fR\fR
300 .sp .6
301 .RS 4n
302 Disable multiple include detection.
306 .ne 2
308 \fB\fB-D-P\fR\fR
312 \fB\fBpp:passthrough\fR\fR
314 .sp .6
315 .RS 4n
316 Enable the non-standard passthrough mode. This can be useful for processing
317 non-C input.
321 .ne 2
323 \fB\fB-D-Q\fR\fR
327 \fB\fBpp:dump\fR\fR
329 .sp .6
330 .RS 4n
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.
336 .ne 2
338 \fB\fB-D-R\fR\fR
342 \fB\fBpp:transition\fR\fR
344 .sp .6
345 .RS 4n
346 Enable the transition preprocessing mode. This is used for compilers that
347 cannot make up their semantics between K&R and ISO C.
351 .ne 2
353 \fB\fB-D-S\fR\fR
357 \fB\fBpp:strict\fR\fR
359 .sp .6
360 .RS 4n
361 Enable strict preprocessing semantics and warnings. This works with any mode
362 (compatibility, transition, or the default ISO).
366 .ne 2
368 \fB\fB-D-T\fR\fItest\fR\fR
372 \fB\fBpp:test\fR \fItest\fR\fR
374 .sp .6
375 .RS 4n
376 Enable implementation specific test code according to \fItest\fR.
380 .ne 2
382 \fB\fB-D-W\fR\fR
386 \fB\fBpp:warn\fR\fR
388 .sp .6
389 .RS 4n
390 Enable pedantic warnings in non-hosted files.
394 .ne 2
396 \fB\fB-D-X\fR\fB[cc]\fR\fR
400 \fB\fB\fR\fR
402 .sp .6
403 .RS 4n
404 Preprocess for the \fBcc\fR compiler, which must be an executable path or an
405 executable on \fB$PATH\fR.
409 .ne 2
411 \fB\fB-D-Z\fR\fR
415 \fB\fBpp:pool\fR\fR
417 .sp .6
418 .RS 4n
419 Enable pool mode.
423 .ne 2
425 \fB\fB-D-d\fR\fR
427 .sp .6
428 .RS 4n
429 List canonicalized \fB#define\fR statements for non-predefined macros in the
430 output.
434 .ne 2
436 \fB\fB-D-m\fR\fR
438 .sp .6
439 .RS 4n
440 List canonicalized \fB#define\fR statements for all macros. All other output is
441 disabled.
445 .ne 2
447 \fB\fB-D-+\fR\fR
451 \fB\fBpp:plusplus\fR\fR
453 .sp .6
454 .RS 4n
455 Preprocess for the C++ dialect.
461 .ne 2
463 \fB\fB-E\fR\fR
467 \fB\fB--preprocess\fR\fR
469 .RS 25n
470 Ignored; for compatibility with very old compilers.
474 .ne 2
476 \fB\fB-H\fR\fR
480 \fB\fB--include-reference\fR\fR
482 .RS 25n
483 Emit \fB#include\fR file paths on the standard error, one per line, indented to
484 show nesting.
488 .ne 2
490 \fB\fB-I\fR\fR
494 \fB\fB--include[=\fR\fIdirectory\fR\fB]\fR\fR
496 .RS 25n
497 Append directory to the list of directories searched for \fB#include\fR files.
499 If directory is \fB-\fR:
500 .RS +4
503 \fB-I\fR directories before \fB-I-\fR are searched only for \fB"..."\fR
504 include files
506 .RS +4
509 \fB-I\fR directories after \fB-I-\fR are searched for \fB"..."\fR and
510 \fB<"...">\fR include files
512 .RS +4
515 the directory \fB\&.\fR is searched only if it is explicitly specified by an
516 \fB-I\fR option
519 .ne 2
521 \fB\fB-I-C\fR\fIdirectory\fR\fR
525 \fB\fBpp:cdir directory\fR\fR
527 .sp .6
528 .RS 4n
529 Mark \fIdirectory\fR as a C header directory. This option is used with
530 \fBpp:plusplus\fR.
534 .ne 2
536 \fB\fB-I-D[\fR\fIfile\fR]\fR
538 .sp .6
539 .RS 4n
540 Read the default \fBprobe\fR definitions from \fIfile\fR, or ignore the default
541 definitions if \fIfile\fR is omitted.
545 .ne 2
547 \fB\fB-I-H\fR\fIdirectory\fR\fR
551 \fB\fBpp:hostdir\fR \fIdirectory\fR\fR
553 .sp .6
554 .RS 4n
555 Mark directory as a hosted directory. Headers from hosted directories have
556 compatibility warnings disabled.
560 .ne 2
562 \fB\fB-I-I\fR\fIheader\fR\fR
566 \fB\fBpp:ignore\fR \fIheader\fR\fR
568 .sp .6
569 .RS 4n
570 Add \fIheader\fR to the list of ignored headers.
574 .ne 2
576 \fB\fB-I-M\fR\fIfile\fR\fR
578 .sp .6
579 .RS 4n
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.
586 .ne 2
588 \fB\fB-I-R\fR\fIfile\fR\fR
590 .sp .6
591 .RS 4n
592 Include \fIfile\fR but do not emit text or line syncs.
596 .ne 2
598 \fB\fB-I-S\fR\fIdirectory\fR\fR
600 .sp .6
601 .RS 4n
602 Add \fIdirectory\fR to the default standard include directory list.
606 .ne 2
608 \fB\fB-I-T\fR\fIfile\fR\fR
610 .sp .6
611 .RS 4n
612 Include \fIfile\fR and emit text to the output file. The option value can be
613 omitted.
619 .ne 2
621 \fB\fB-M\fR\fR
625 \fB\fB--dependencies\fR\fR
627 .RS 25n
628 Generate \fBmake\fR(1S) dependencies. This option is not needed with
629 \fBnmake\fR.
631 The \fB-M\fR option can be followed by optional flags to change the dependency
632 output styles.
634 The following optional flags are supported:
636 .ne 2
638 \fB\fBD\fR\fR
640 .RS 5n
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.
646 .ne 2
648 \fB\fBG\fR\fR
650 .RS 5n
651 Also generate missing dependencies.
655 .ne 2
657 \fB\fBM\fR\fR
659 .RS 5n
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.
669 .ne 2
671 \fB\fB-P\fR\fR
675 \fB\fB--sync\fR\fR
677 .RS 25n
678 Emit line syncs.
680 Line sync is turned on by default. \fB-P\fR means \fB--nosync\fR.
684 .ne 2
686 \fB\fB-T\fR\fB[\fR\fIlength\fR\fB]\fR\fR
688 .RS 25n
689 If not \fBgcc\fR, truncate identifiers to \fIlength\fR characters for
690 compatibility with old AT&T compilers.
694 .ne 2
696 \fB\fB-U\fR\fR
700 \fB\fB--undefine=\fR\fIname\fR\fR
702 .RS 25n
703 Remove the definition for the macro \fIname\fR.
707 .ne 2
709 \fB\fB-V\fR\fR
713 \fB\fB--version\fR\fR
715 .RS 25n
716 Emit the \fBlibpp\fR version.
720 .ne 2
722 \fB\fB-X\fR\fR
726 \fB\fB--argmode\fR\fR
728 .RS 25n
729 Enable \fIname\fR\fB=\fR\fIvalue\fR macro arguments for \fBeasel\fR
730 compatibility.
734 .ne 2
736 \fB\fB-Y\fR\fR
740 \fB\fB--standard=\fR\fIdirectory\fR\fR
742 .RS 25n
743 Add \fIdirectory\fR to the list searched for \fB#include <...>\fR files.
746 .SH OPERANDS
749 The following operands are supported:
751 .ne 2
753 \fB\fIinput\fR\fR
755 .RS 10n
756 Specifies C source file to preprocess.
760 .ne 2
762 \fB\fIoutput\fR\fR
764 .RS 10n
765 Specifies output file.
768 .SH EXIT STATUS
770 .ne 2
772 \fB\fB0\fR\fR
774 .RS 6n
775 Successful completion.
779 .ne 2
781 \fB\fB>0\fR\fR
783 .RS 6n
784 An error occurred.
787 .SH EXAMPLES
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:
797 .in +2
799 example% cat hello.c
802 #include <stdio.h>
803 #include <stdlib.h>
806  * dummy macro to avoid including
807  * libast headers
808  */
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
821 str "hello world"
822 str "hello all"
824 .in -2
827 .SH AUTHORS
830 Glenn Fowler, \fBgsf@research.att.com\fR
831 .SH ATTRIBUTES
834 See \fBattributes\fR(5) for descriptions of the following attributes:
839 box;
840 c | c
841 l | l .
842 ATTRIBUTE TYPE  ATTRIBUTE VALUE
844 Interface Stability     Volatile
847 .SH SEE ALSO
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,
855 Prentice Hall, 1988.