1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
|
'\" te
.\" Copyright (c) 1986-2006 AT&T Knowledge Ventures
.\" To view license terms, see http://www.opensource.org/licenses/cpl1.0.txt
.\" Portions Copyright (c) 2007, Sun Microsystems, Inc.
.TH MSGCPP 1 "Oct 9, 2007"
.SH NAME
msgcpp \- C language message catalog preprocessor
.SH SYNOPSIS
.LP
.nf
\fBmsgcpp\fR [\fB-ACEHMPVX\fR] [\fB-D\fR \fIname\fR[\fB=\fR\fIvalue\fR]] [\fB-I\fR \fIdirectory\fR] [\fB-U\fR \fIname\fR]
[\fB-T\fR[\fIlength\fR]] [\fB-Y\fR \fIdirectory\fR] [\fIinput\fR [\fIoutput\fR] ]
.fi
.SH DESCRIPTION
.sp
.LP
\fBmsgcpp\fR is a C language message catalog preprocessor. It accepts
\fBcpp\fR(1) style options and arguments. \fBmsgcpp\fR preprocesses an input C
source file and emits keyed lines to the output, usually for further processing
by \fBmsgcc\fR(1). \fBmsgcc\fR output is in the \fBgencat\fR(1) syntax.
Candidate message text is determined by arguments to the last \fB<error.h>\fR
and \fB<option.h>\fR functions. The \fBmsgcpp\fR keyed output lines are:
.sp
.ne 2
.na
\fB\fBcmd\fR \fIcommand\fR\fR
.ad
.RS 19n
\fIcommand\fR is a candidate for \fB--??keys\fR option string generation. This
is triggered by \fBb_command(int argc\fR, in the input.
.RE
.sp
.ne 2
.na
\fB\fBdef\fR \fIname string\fR\fR
.ad
.RS 19n
\fIname\fR is a candidate variable with \fIstring\fR value string.
.RE
.sp
.ne 2
.na
\fB\fBstr\fR \fIstring\fR\fR
.ad
.RS 19n
\fIstring\fR should be entered into the catalog.
.RE
.sp
.ne 2
.na
\fB\fBvar\fR \fIname\fR\fR
.ad
.RS 19n
If \fBdef\fR \fIname\fR occurs then its string value should be entered into the
catalog.
.RE
.sp
.LP
The input source file is preprocessed with the \fBpp:allpossible\fR option on.
This enables non-C semantics. All source should first be compiled error-free
with a real compiler before running \fBmsgcpp\fR. The following changes are
enabled for the top level files. Included file behavior is not affected.
.RS +4
.TP
1.
All \fB#if\fR, \fB#ifdef\fR and \fB#ifndef\fR branches are enabled.
.RE
.RS +4
.TP
2.
The first definition for a macro is retained, even when subsequent
\fB#define\fR statements would normally redefine the macro. \fB#undef\fR must
be used to redefine a macro.
.RE
.RS +4
.TP
3.
Macro calls with an improper number of arguments are silently ignored.
.RE
.RS +4
.TP
4.
\fB#include\fR on non-existent headers are silently ignored.
.RE
.RS +4
.TP
5.
Invalid C source characters are silently ignored.
.RE
.sp
.LP
\fBmsgcat.h\fR is included if it exists. This file may contain macro
definitions for functions that translate string arguments. If \fBfoo\fR is a
function that translates its string arguments then include the line \fB#define
foo _TRANSLATE_\fR in \fBmsgcat.h\fR, or specify the option
\fB-Dfoo=_TRANSLATE_\fR. If \fBbar\fR is a function that translates string
arguments if the first argument is \fBstderr\fR, then use either \fB#define bar
_STDIO_\fR or \fB-Dbar=_STDIO_\fR.
.sp
.LP
The macro \fB_BLD_msgcat\fR is defined to be \fB1\fR. As an alternative to
\fBmsgcat.h\fR, \fB_TRANSLATE_\fR definitions could be placed inside \fB#ifdef
_BLD_msgcat ... #endif\fR.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-A\fR\fR
.ad
.br
.na
\fB\fB--assert=\fR\fIassertion\fR\fR
.ad
.RS 25n
Enter the assertion using \fB#assert\fR for system V compatibility.
.RE
.sp
.ne 2
.na
\fB\fB-C\fR\fR
.ad
.br
.na
\fB\fB--comments\fR\fR
.ad
.RS 25n
Pass comments to the output.
.sp
Comments are omitted by default.
.RE
.sp
.ne 2
.na
\fB\fB-D\fR\fR
.ad
.br
.na
\fB\fB--define=\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]\fR\fR
.ad
.RS 25n
Define the macro \fIname\fR to have \fIvalue\fR. This is the only portable way
to pass options through \fBcc\fR to \fBcpp\fR(1).
.RS +4
.TP
.ie t \(bu
.el o
If \fB=\fR\fIvalue\fR is omitted, \fIvalue\fR is assumed to be \fB1\fR .
.RE
.RS +4
.TP
.ie t \(bu
.el o
If \fIname\fR begins with \fB:\fR, then it is interpreted as a \fBlibpp\fR
\fB#pragma pp\fR: statement.
.RE
.RS +4
.TP
.ie t \(bu
.el o
If \fIname\fR begins with \fB%\fR, it is interpreted as a \fBlibpp\fR \fB#\fR
directive statement.
.RE
.RS +4
.TP
.ie t \(bu
.el o
If name begins with a \fB-\fR or a \fB+\fR, it is interpreted as a \fBlibpp\fR
option.
.sp
\fB-\fR turns the option on, \fB+\fR turns it off.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Most options have a \fB#pragma\fR counterpart that is listed with the option
definition.
.RE
.sp
.ne 2
.na
\fB\fB-D-C\fR\fR
.ad
.br
.na
\fB\fBpp:compatibility\fR\fR
.ad
.sp .6
.RS 4n
Preprocess for K&R C compatibility.
.RE
.sp
.ne 2
.na
\fB\fB-D-D\fR\fIlevel\fR\fR
.ad
.br
.na
\fB\fBpp:debug level\fR \fIlevel\fR\fR
.ad
.sp .6
.RS 4n
Set the debug trace level.
.sp
Specify \fIlevel\fR as a number greater than or equal to \fB0\fR. Higher levels
produce more output. Levels higher than \fB3\fR can only be enabled in the
\fB-g\fR compiled versions.
.RE
.sp
.ne 2
.na
\fB\fB-D-F\fR\fIname\fR\fR
.ad
.sp .6
.RS 4n
Set the main input file name to \fIname\fR. This only affects the error
messages and the line sync output.
.RE
.sp
.ne 2
.na
\fB\fB-D-H\fR\fR
.ad
.br
.na
\fB\fBpp:hosted\fR\fR
.ad
.sp .6
.RS 4n
All directories are hosted. Compatibility warning messages from the hosted
directory headers are suppressed.
.RE
.sp
.ne 2
.na
\fB\fB-D-I\fR\fR
.ad
.br
.na
\fB\fBpp:cdir\fR\fR
.ad
.sp .6
.RS 4n
All directories contain C headers. This option is only used only with
\fB-D-+\fR.
.RE
.sp
.ne 2
.na
\fB\fB-D-K\fR\fR
.ad
.br
.na
\fB\fBpp:keyargs\fR\fR
.ad
.sp .6
.RS 4n
Enable the non-standard \fIname\fR\fB=\fR\fIvalue\fR macro argument mode.
.RE
.sp
.ne 2
.na
\fB\fB-D-L\fR\fB[\fR\fIid\fR\fB]\fR\fR
.ad
.br
.na
\fB\fBpp:lineid [\fR\fIid\fR]\fR
.ad
.sp .6
.RS 4n
Set the line sync directive id to \fIid\fR. If \fIid\fR is not specified, set
to null.
.RE
.sp
.ne 2
.na
\fB\fB-D-M\fR\fR
.ad
.br
.na
\fB\fBpp:nomultiple\fR\fR
.ad
.sp .6
.RS 4n
Disable multiple include detection.
.RE
.sp
.ne 2
.na
\fB\fB-D-P\fR\fR
.ad
.br
.na
\fB\fBpp:passthrough\fR\fR
.ad
.sp .6
.RS 4n
Enable the non-standard passthrough mode. This can be useful for processing
non-C input.
.RE
.sp
.ne 2
.na
\fB\fB-D-Q\fR\fR
.ad
.br
.na
\fB\fBpp:dump\fR\fR
.ad
.sp .6
.RS 4n
Dump macro definitions to the output so that the output may be passed through
\fBcpp\fR again. This is used for generating precompiled headers.
.RE
.sp
.ne 2
.na
\fB\fB-D-R\fR\fR
.ad
.br
.na
\fB\fBpp:transition\fR\fR
.ad
.sp .6
.RS 4n
Enable the transition preprocessing mode. This is used for compilers that
cannot make up their semantics between K&R and ISO C.
.RE
.sp
.ne 2
.na
\fB\fB-D-S\fR\fR
.ad
.br
.na
\fB\fBpp:strict\fR\fR
.ad
.sp .6
.RS 4n
Enable strict preprocessing semantics and warnings. This works with any mode
(compatibility, transition, or the default ISO).
.RE
.sp
.ne 2
.na
\fB\fB-D-T\fR\fItest\fR\fR
.ad
.br
.na
\fB\fBpp:test\fR \fItest\fR\fR
.ad
.sp .6
.RS 4n
Enable implementation specific test code according to \fItest\fR.
.RE
.sp
.ne 2
.na
\fB\fB-D-W\fR\fR
.ad
.br
.na
\fB\fBpp:warn\fR\fR
.ad
.sp .6
.RS 4n
Enable pedantic warnings in non-hosted files.
.RE
.sp
.ne 2
.na
\fB\fB-D-X\fR\fB[cc]\fR\fR
.ad
.br
.na
\fB\fB\fR\fR
.ad
.sp .6
.RS 4n
Preprocess for the \fBcc\fR compiler, which must be an executable path or an
executable on \fB$PATH\fR.
.RE
.sp
.ne 2
.na
\fB\fB-D-Z\fR\fR
.ad
.br
.na
\fB\fBpp:pool\fR\fR
.ad
.sp .6
.RS 4n
Enable pool mode.
.RE
.sp
.ne 2
.na
\fB\fB-D-d\fR\fR
.ad
.sp .6
.RS 4n
List canonicalized \fB#define\fR statements for non-predefined macros in the
output.
.RE
.sp
.ne 2
.na
\fB\fB-D-m\fR\fR
.ad
.sp .6
.RS 4n
List canonicalized \fB#define\fR statements for all macros. All other output is
disabled.
.RE
.sp
.ne 2
.na
\fB\fB-D-+\fR\fR
.ad
.br
.na
\fB\fBpp:plusplus\fR\fR
.ad
.sp .6
.RS 4n
Preprocess for the C++ dialect.
.RE
.RE
.sp
.ne 2
.na
\fB\fB-E\fR\fR
.ad
.br
.na
\fB\fB--preprocess\fR\fR
.ad
.RS 25n
Ignored; for compatibility with very old compilers.
.RE
.sp
.ne 2
.na
\fB\fB-H\fR\fR
.ad
.br
.na
\fB\fB--include-reference\fR\fR
.ad
.RS 25n
Emit \fB#include\fR file paths on the standard error, one per line, indented to
show nesting.
.RE
.sp
.ne 2
.na
\fB\fB-I\fR\fR
.ad
.br
.na
\fB\fB--include[=\fR\fIdirectory\fR\fB]\fR\fR
.ad
.RS 25n
Append directory to the list of directories searched for \fB#include\fR files.
.sp
If directory is \fB-\fR:
.RS +4
.TP
1.
\fB-I\fR directories before \fB-I-\fR are searched only for \fB"..."\fR
include files
.RE
.RS +4
.TP
2.
\fB-I\fR directories after \fB-I-\fR are searched for \fB"..."\fR and
\fB<"...">\fR include files
.RE
.RS +4
.TP
3.
the directory \fB\&.\fR is searched only if it is explicitly specified by an
\fB-I\fR option
.RE
.sp
.ne 2
.na
\fB\fB-I-C\fR\fIdirectory\fR\fR
.ad
.br
.na
\fB\fBpp:cdir directory\fR\fR
.ad
.sp .6
.RS 4n
Mark \fIdirectory\fR as a C header directory. This option is used with
\fBpp:plusplus\fR.
.RE
.sp
.ne 2
.na
\fB\fB-I-D[\fR\fIfile\fR]\fR
.ad
.sp .6
.RS 4n
Read the default \fBprobe\fR definitions from \fIfile\fR, or ignore the default
definitions if \fIfile\fR is omitted.
.RE
.sp
.ne 2
.na
\fB\fB-I-H\fR\fIdirectory\fR\fR
.ad
.br
.na
\fB\fBpp:hostdir\fR \fIdirectory\fR\fR
.ad
.sp .6
.RS 4n
Mark directory as a hosted directory. Headers from hosted directories have
compatibility warnings disabled.
.RE
.sp
.ne 2
.na
\fB\fB-I-I\fR\fIheader\fR\fR
.ad
.br
.na
\fB\fBpp:ignore\fR \fIheader\fR\fR
.ad
.sp .6
.RS 4n
Add \fIheader\fR to the list of ignored headers.
.RE
.sp
.ne 2
.na
\fB\fB-I-M\fR\fIfile\fR\fR
.ad
.sp .6
.RS 4n
\fIfile\fR contains a sequence of header \fB[= "map" ]\fR lines, where header
is either \fB<name>\fR or \fB"name"\fR, and \fB"map"\fR is an explicit binding
for header. header is ignored \fBif = "map"\fR is omitted.
.RE
.sp
.ne 2
.na
\fB\fB-I-R\fR\fIfile\fR\fR
.ad
.sp .6
.RS 4n
Include \fIfile\fR but do not emit text or line syncs.
.RE
.sp
.ne 2
.na
\fB\fB-I-S\fR\fIdirectory\fR\fR
.ad
.sp .6
.RS 4n
Add \fIdirectory\fR to the default standard include directory list.
.RE
.sp
.ne 2
.na
\fB\fB-I-T\fR\fIfile\fR\fR
.ad
.sp .6
.RS 4n
Include \fIfile\fR and emit text to the output file. The option value can be
omitted.
.RE
.RE
.sp
.ne 2
.na
\fB\fB-M\fR\fR
.ad
.br
.na
\fB\fB--dependencies\fR\fR
.ad
.RS 25n
Generate \fBmake\fR(1S) dependencies. This option is not needed with
\fBnmake\fR.
.sp
The \fB-M\fR option can be followed by optional flags to change the dependency
output styles.
.sp
The following optional flags are supported:
.sp
.ne 2
.na
\fB\fBD\fR\fR
.ad
.RS 5n
Generate dependencies in a separate \fB\&.d\fR file. Preprocessed output is
still written to output, or the standard output if output is omitted.
.RE
.sp
.ne 2
.na
\fB\fBG\fR\fR
.ad
.RS 5n
Also generate missing dependencies.
.RE
.sp
.ne 2
.na
\fB\fBM\fR\fR
.ad
.RS 5n
Only generate local header dependencies. Hosted headers are omitted. Hosted
headers are determined by the \fB-I-H\fR option and the -\fB-pp:hosted\fR and
\fBpp:hostdir pragmas\fR. No special distinction is made between the \fB""\fR
and \fB<>\fR include styles.
.RE
.RE
.sp
.ne 2
.na
\fB\fB-P\fR\fR
.ad
.br
.na
\fB\fB--sync\fR\fR
.ad
.RS 25n
Emit line syncs.
.sp
Line sync is turned on by default. \fB-P\fR means \fB--nosync\fR.
.RE
.sp
.ne 2
.na
\fB\fB-T\fR\fB[\fR\fIlength\fR\fB]\fR\fR
.ad
.RS 25n
If not \fBgcc\fR, truncate identifiers to \fIlength\fR characters for
compatibility with old AT&T compilers.
.RE
.sp
.ne 2
.na
\fB\fB-U\fR\fR
.ad
.br
.na
\fB\fB--undefine=\fR\fIname\fR\fR
.ad
.RS 25n
Remove the definition for the macro \fIname\fR.
.RE
.sp
.ne 2
.na
\fB\fB-V\fR\fR
.ad
.br
.na
\fB\fB--version\fR\fR
.ad
.RS 25n
Emit the \fBlibpp\fR version.
.RE
.sp
.ne 2
.na
\fB\fB-X\fR\fR
.ad
.br
.na
\fB\fB--argmode\fR\fR
.ad
.RS 25n
Enable \fIname\fR\fB=\fR\fIvalue\fR macro arguments for \fBeasel\fR
compatibility.
.RE
.sp
.ne 2
.na
\fB\fB-Y\fR\fR
.ad
.br
.na
\fB\fB--standard=\fR\fIdirectory\fR\fR
.ad
.RS 25n
Add \fIdirectory\fR to the list searched for \fB#include <...>\fR files.
.RE
.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIinput\fR\fR
.ad
.RS 10n
Specifies C source file to preprocess.
.RE
.sp
.ne 2
.na
\fB\fIoutput\fR\fR
.ad
.RS 10n
Specifies output file.
.RE
.SH EXIT STATUS
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE
.SH EXAMPLES
.LP
\fBExample 1 \fRUsing \fBmsgcpp\fR to Extract Localizable Strings
.sp
.LP
The following example uses \fBmsgcpp\fR to extract localizable strings from the
file \fBhello.c\fR, marked using the \fBERROR_dictionary()\fR, and writes them
to the file \fBhello.mso\fR:
.sp
.in +2
.nf
example% cat hello.c
#include <stdio.h>
#include <stdlib.h>
/*
* dummy macro to avoid including
* libast headers
*/
#define ERROR_dictionary(x) x
int main(int ac, char *av[])
{
puts( ERROR_dictionary("hello world") );
puts( ERROR_dictionary("hello all") );
return( EXIT_SUCCESS );
}
example% msgcpp -D__STDC__ -D__i386 hello.c hello.mso
example% cat hello.mso
str "hello world"
str "hello all"
.fi
.in -2
.sp
.SH AUTHORS
.sp
.LP
Glenn Fowler, \fBgsf@research.att.com\fR
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Volatile
.TE
.SH SEE ALSO
.sp
.LP
.BR cpp (1),
.BR gencat (1),
.BR msgcc (1),
.BR msgcvt (1),
.BR msggen (1),
.BR make (1S),
.BR attributes (7)
.sp
.LP
Kernighan, Brian W. and Ritchie, Dennis M., \fIThe C Programming Language\fR,
Prentice Hall, 1988.
|