1msgcpp(1) User Commands msgcpp(1)
2
3
4
6 msgcpp - C language message catalog preprocessor
7
9 msgcpp [-ACEHMPVX] [-D name[=value]] [-I directory] [-U name]
10 [-T[length]] [-Y directory] [input [output] ]
11
12
14 msgcpp is a C language message catalog preprocessor. It accepts cpp(1)
15 style options and arguments. msgcpp preprocesses an input C source file
16 and emits keyed lines to the output, usually for further processing
17 bymsgcc(1). msgcc output is in the gencat(1) syntax. Candidate message
18 text is determined by arguments to the last <error.h> and <option.h>
19 functions. The msgcpp keyed output lines are:
20
21 cmd command command is a candidate for --??keys option string
22 generation. This is triggered by b_command(int argc,
23 in the input.
24
25
26 def name string name is a candidate variable with string value
27 string.
28
29
30 str string string should be entered into the catalog.
31
32
33 var name If def name occurs then its string value should be
34 entered into the catalog.
35
36
37
38 The input source file is preprocessed with the pp:allpossible option
39 on. This enables non-C semantics. All source should first be compiled
40 error-free with a real compiler before running msgcpp. The following
41 changes are enabled for the top level files. Included file behavior is
42 not affected.
43
44 1. All #if, #ifdef and #ifndef branches are enabled.
45
46 2. The first definition for a macro is retained, even when sub‐
47 sequent #define statements would normally redefine the
48 macro. #undef must be used to redefine a macro.
49
50 3. Macro calls with an improper number of arguments are
51 silently ignored.
52
53 4. #include on non-existent headers are silently ignored.
54
55 5. Invalid C source characters are silently ignored.
56
57
58 msgcat.h is included if it exists. This file may contain macro defini‐
59 tions for functions that translate string arguments. If foo is a func‐
60 tion that translates its string arguments then include the line #define
61 foo _TRANSLATE_ in msgcat.h, or specify the option -Dfoo=_TRANSLATE_.
62 If bar is a function that translates string arguments if the first
63 argument is stderr, then use either #define bar _STDIO_ or
64 -Dbar=_STDIO_.
65
66
67 The macro _BLD_msgcat is defined to be 1. As an alternative to msg‐
68 cat.h, _TRANSLATE_ definitions could be placed inside #ifdef _BLD_msg‐
69 cat ... #endif.
70
72 The following options are supported:
73
74 -A Enter the assertion using #assert for system V
75 --assert=assertion compatibility.
76
77
78 -C Pass comments to the output.
79 --comments
80 Comments are omitted by default.
81
82
83 -D Define the macro name to have value. This is
84 --define=name[=value] the only portable way to pass options through
85 cc to cpp(1).
86
87 o If =value is omitted, value is
88 assumed to be 1 .
89
90 o If name begins with :, then it is
91 interpreted as a libpp #pragma pp:
92 statement.
93
94 o If name begins with %, it is inter‐
95 preted as a libpp # directive
96 statement.
97
98 o If name begins with a - or a +, it
99 is interpreted as a libpp option.
100
101 - turns the option on, + turns it
102 off.
103
104 o Most options have a #pragma coun‐
105 terpart that is listed with the
106 option definition.
107
108 -D-C
109 pp:compatibility
110
111 Preprocess for K&R C compatibility.
112
113
114 -D-Dlevel
115 pp:debug level level
116
117 Set the debug trace level.
118
119 Specify level as a number greater than or
120 equal to 0. Higher levels produce more
121 output. Levels higher than 3 can only be
122 enabled in the -g compiled versions.
123
124
125 -D-Fname
126
127 Set the main input file name to name. This
128 only affects the error messages and the
129 line sync output.
130
131
132 -D-H
133 pp:hosted
134
135 All directories are hosted. Compatibility
136 warning messages from the hosted directory
137 headers are suppressed.
138
139
140 -D-I
141 pp:cdir
142
143 All directories contain C headers. This
144 option is only used only with -D-+.
145
146
147 -D-K
148 pp:keyargs
149
150 Enable the non-standard name=value macro
151 argument mode.
152
153
154 -D-L[id]
155 pp:lineid [id]
156
157 Set the line sync directive id to id. If
158 id is not specified, set to null.
159
160
161 -D-M
162 pp:nomultiple
163
164 Disable multiple include detection.
165
166
167 -D-P
168 pp:passthrough
169
170 Enable the non-standard passthrough mode.
171 This can be useful for processing non-C
172 input.
173
174
175 -D-Q
176 pp:dump
177
178 Dump macro definitions to the output so
179 that the output may be passed through cpp
180 again. This is used for generating precom‐
181 piled headers.
182
183
184 -D-R
185 pp:transition
186
187 Enable the transition preprocessing mode.
188 This is used for compilers that cannot
189 make up their semantics between K&R and
190 ISO C.
191
192
193 -D-S
194 pp:strict
195
196 Enable strict preprocessing semantics and
197 warnings. This works with any mode (com‐
198 patibility, transition, or the default
199 ISO).
200
201
202 -D-Ttest
203 pp:test test
204
205 Enable implementation specific test code
206 according to test.
207
208
209 -D-W
210 pp:warn
211
212 Enable pedantic warnings in non-hosted
213 files.
214
215
216 -D-X[cc]
217
218
219 Preprocess for the cc compiler, which must
220 be an executable path or an executable on
221 $PATH.
222
223
224 -D-Z
225 pp:pool
226
227 Enable pool mode.
228
229
230 -D-d
231
232 List canonicalized #define statements for
233 non-predefined macros in the output.
234
235
236 -D-m
237
238 List canonicalized #define statements for
239 all macros. All other output is disabled.
240
241
242 -D-+
243 pp:plusplus
244
245 Preprocess for the C++ dialect.
246
247
248
249 -E Ignored; for compatibility with very old com‐
250 --preprocess pilers.
251
252
253 -H Emit #include file paths on the standard
254 --include-reference error, one per line, indented to show nesting.
255
256
257 -I Append directory to the list of directories
258 --include[=directory] searched for #include files.
259
260 If directory is -:
261
262 1. -I directories before -I- are
263 searched only for "..." include
264 files
265
266 2. -I directories after -I- are
267 searched for "..." and <"...">
268 include files
269
270 3. the directory . is searched only if
271 it is explicitly specified by an -I
272 option
273
274 -I-Cdirectory
275 pp:cdir directory
276
277 Mark directory as a C header directory.
278 This option is used with pp:plusplus.
279
280
281 -I-D[file]
282
283 Read the default probe definitions from
284 file, or ignore the default definitions if
285 file is omitted.
286
287
288 -I-Hdirectory
289 pp:hostdir directory
290
291 Mark directory as a hosted directory.
292 Headers from hosted directories have com‐
293 patibility warnings disabled.
294
295
296 -I-Iheader
297 pp:ignore header
298
299 Add header to the list of ignored headers.
300
301
302 -I-Mfile
303
304 file contains a sequence of header [=
305 "map" ] lines, where header is either
306 <name> or "name", and "map" is an explicit
307 binding for header. header is ignored if =
308 "map" is omitted.
309
310
311 -I-Rfile
312
313 Include file but do not emit text or line
314 syncs.
315
316
317 -I-Sdirectory
318
319 Add directory to the default standard
320 include directory list.
321
322
323 -I-Tfile
324
325 Include file and emit text to the output
326 file. The option value can be omitted.
327
328
329
330 -M Generate make(1S) dependencies. This option is
331 --dependencies not needed with nmake.
332
333 The -M option can be followed by optional
334 flags to change the dependency output styles.
335
336 The following optional flags are supported:
337
338 D Generate dependencies in a separate .d
339 file. Preprocessed output is still writ‐
340 ten to output, or the standard output if
341 output is omitted.
342
343
344 G Also generate missing dependencies.
345
346
347 M Only generate local header dependencies.
348 Hosted headers are omitted. Hosted head‐
349 ers are determined by the -I-H option and
350 the --pp:hosted and pp:hostdir pragmas.
351 No special distinction is made between
352 the "" and <> include styles.
353
354
355
356 -P Emit line syncs.
357 --sync
358 Line sync is turned on by default. -P means
359 --nosync.
360
361
362 -T[length] If not gcc, truncate identifiers to length
363 characters for compatibility with old AT&T
364 compilers.
365
366
367 -U Remove the definition for the macro name.
368 --undefine=name
369
370 -V Emit the libpp version.
371 --version
372
373 -X Enable name=value macro arguments for easel
374 --argmode compatibility.
375
376
377 -Y Add directory to the list searched for
378 --standard=directory #include <...> files.
379
380
382 The following operands are supported:
383
384 input Specifies C source file to preprocess.
385
386
387 output Specifies output file.
388
389
391 0 Successful completion.
392
393
394 >0 An error occurred.
395
396
398 Example 1 Using msgcpp to Extract Localizable Strings
399
400
401 The following example uses msgcpp to extract localizable strings from
402 the file hello.c, marked using the ERROR_dictionary(), and writes them
403 to the file hello.mso:
404
405
406 example% cat hello.c
407
408
409 #include <stdio.h>
410 #include <stdlib.h>
411
412 /*
413 * dummy macro to avoid including
414 * libast headers
415 */
416 #define ERROR_dictionary(x) x
417
418 int main(int ac, char *av[])
419 {
420 puts( ERROR_dictionary("hello world") );
421 puts( ERROR_dictionary("hello all") );
422 return( EXIT_SUCCESS );
423 }
424
425 example% msgcpp -D__STDC__ -D__i386 hello.c hello.mso
426
427 example% cat hello.mso
428 str "hello world"
429 str "hello all"
430
431
432
434 Glenn Fowler, gsf@research.att.com
435
437 See attributes(5) for descriptions of the following attributes:
438
439
440
441
442 ┌─────────────────────────────┬─────────────────────────────┐
443 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
444 ├─────────────────────────────┼─────────────────────────────┤
445 │Availability │SUNWastdev │
446 ├─────────────────────────────┼─────────────────────────────┤
447 │Interface Stability │Volatile │
448 └─────────────────────────────┴─────────────────────────────┘
449
451 cpp(1), gencat(1), msgcc(1), msgcvt(1), msggen(1), make(1S),
452 attributes(5)
453
454
455 Kernighan, Brian W. and Ritchie, Dennis M., The C Programming Language,
456 Prentice Hall, 1988.
457
458
459
460SunOS 5.11 9 Oct 2007 msgcpp(1)