Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, July 27, 2022

msgcpp (1)


msgcpp - C language message catalog preprocessor


msgcpp [-ACEHMPVX] [-D name[=value]] [-I directory] [-U name]
[-T[length]] [-Y directory] [input [output] ]


msgcpp(1)                        User Commands                       msgcpp(1)

       msgcpp - C language message catalog preprocessor

       msgcpp [-ACEHMPVX] [-D name[=value]] [-I directory] [-U name]
        [-T[length]] [-Y directory] [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
       bymsgcc(1). msgcc output is in the gencat(1) syntax. Candidate  message
       text  is  determined  by arguments to the last <error.h> and <option.h>
       functions. The msgcpp keyed output lines are:

       cmd command        command is a candidate for  --??keys  option  string
                          generation. This is triggered by b_command(int argc,
                          in the input.

       def name string    name is  a  candidate  variable  with  string  value

       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. Included file behavior is
       not affected.

           1.     All #if, #ifdef and #ifndef branches are enabled.

           2.     The first definition for a macro is retained, even when sub-
                  sequent  #define  statements  would  normally  redefine  the
                  macro. #undef must be used to redefine a macro.

           3.     Macro  calls  with  an  improper  number  of  arguments  are
                  silently ignored.

           4.     #include on non-existent headers are silently ignored.

           5.     Invalid C source characters are silently ignored.

       msgcat.h  is included if it exists. This file may contain macro defini-
       tions for functions that translate string arguments. If foo is a  func-
       tion 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

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

       The following options are supported:

       -A                       Enter the assertion using #assert for system V
       --assert=assertion       compatibility.

       -C                       Pass comments to the output.
                                Comments are omitted by default.

       -D                       Define the macro name to have value.  This  is
       --define=name[=value]    the  only portable way to pass options through
                                cc to cpp(1).

                                    o      If  =value  is  omitted,  value  is
                                           assumed to be 1 .

                                    o      If  name  begins with :, then it is
                                           interpreted as a libpp #pragma  pp:

                                    o      If name begins with %, it is inter-
                                           preted  as  a  libpp  #   directive

                                    o      If  name begins with a - or a +, it
                                           is interpreted as a libpp option.

                                           - turns the option on, +  turns  it

                                    o      Most  options  have a #pragma coun-
                                           terpart that  is  listed  with  the
                                           option definition.


                                    Preprocess for K&R C compatibility.

                                pp:debug level level

                                    Set the debug trace level.

                                    Specify  level as a number greater than or
                                    equal to 0.  Higher  levels  produce  more
                                    output.  Levels  higher than 3 can only be
                                    enabled in the -g compiled versions.


                                    Set the main input file name to name. This
                                    only  affects  the  error messages and the
                                    line sync output.


                                    All directories are hosted.  Compatibility
                                    warning messages from the hosted directory
                                    headers are suppressed.


                                    All directories contain  C  headers.  This
                                    option is only used only with -D-+.


                                    Enable  the  non-standard name=value macro
                                    argument mode.

                                pp:lineid [id]

                                    Set the line sync directive id to  id.  If
                                    id is not specified, set to null.


                                    Disable multiple include detection.


                                    Enable  the non-standard passthrough mode.
                                    This can be useful  for  processing  non-C


                                    Dump  macro  definitions  to the output so
                                    that the output may be passed through  cpp
                                    again. This is used for generating precom-
                                    piled headers.


                                    Enable the transition preprocessing  mode.
                                    This  is  used  for  compilers that cannot
                                    make up their semantics  between  K&R  and
                                    ISO C.


                                    Enable  strict preprocessing semantics and
                                    warnings. This works with any  mode  (com-
                                    patibility,  transition,  or  the  default

                                pp:test test

                                    Enable implementation specific  test  code
                                    according to test.


                                    Enable  pedantic  warnings  in  non-hosted


                                    Preprocess for the cc compiler, which must
                                    be  an executable path or an executable on


                                    Enable pool mode.


                                    List canonicalized #define statements  for
                                    non-predefined macros in the output.


                                    List  canonicalized #define statements for
                                    all macros. All other output is disabled.


                                    Preprocess for the C++ dialect.

       -E                       Ignored; for compatibility with very old  com-
       --preprocess             pilers.

       -H                       Emit  #include  file  paths  on  the  standard
       --include-reference      error, one per line, indented to show nesting.

       -I                       Append directory to the  list  of  directories
       --include[=directory]    searched for #include files.

                                If directory is -:

                                    1.     -I   directories   before  -I-  are
                                           searched  only  for  "..."  include

                                    2.     -I   directories   after   -I-  are
                                           searched  for  "..."  and   <"...">
                                           include files

                                    3.     the directory . is searched only if
                                           it is explicitly specified by an -I

                                pp:cdir directory

                                    Mark  directory  as  a C header directory.
                                    This option is used with pp:plusplus.


                                    Read the default  probe  definitions  from
                                    file, or ignore the default definitions if
                                    file is omitted.

                                pp:hostdir directory

                                    Mark  directory  as  a  hosted  directory.
                                    Headers  from hosted directories have com-
                                    patibility warnings disabled.

                                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


                                    Add  directory  to  the  default  standard
                                    include directory list.


                                    Include file and emit text to  the  output
                                    file. The option value can be omitted.

       -M                       Generate make(1S) dependencies. This option is
       --dependencies           not needed with nmake.

                                The -M option  can  be  followed  by  optional
                                flags to change the dependency output styles.

                                The following optional flags are supported:

                                D    Generate  dependencies  in  a separate .d
                                     file. Preprocessed output is still  writ-
                                     ten  to output, or the standard output if
                                     output is omitted.

                                G    Also generate missing dependencies.

                                M    Only generate local header  dependencies.
                                     Hosted  headers are omitted. Hosted head-
                                     ers are determined by the -I-H option and
                                     the  --pp:hosted  and pp:hostdir pragmas.
                                     No special distinction  is  made  between
                                     the "" and <> include styles.

       -P                       Emit line syncs.
                                Line  sync  is  turned on by default. -P means

       -T[length]               If not gcc,  truncate  identifiers  to  length
                                characters  for  compatibility  with  old AT&T

       -U                       Remove the definition for the macro name.

       -V                       Emit the libpp version.

       -X                       Enable name=value macro  arguments  for  easel
       --argmode                compatibility.

       -Y                       Add   directory   to  the  list  searched  for
       --standard=directory     #include <...> files.

       The following operands are supported:

       input     Specifies C source file to preprocess.

       output    Specifies output file.

       0     Successful completion.

       >0    An error occurred.

       Example 1 Using msgcpp to Extract Localizable Strings

       The following example uses msgcpp to extract localizable  strings  from
       the  file hello.c, marked using the ERROR_dictionary(), and writes them
       to the file hello.mso:

         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"

       Glenn Fowler, gsf@research.att.com

       See attributes(7) for descriptions of the following attributes:

       |      ATTRIBUTE TYPE         |      ATTRIBUTE VALUE        |
       |Availability                 |developer/astdev             |
       |Interface Stability          |Volatile                     |

       cpp(1),   gencat(1),   msgcc(1),   msgcvt(1),   msggen(1),    make(1S),

       Kernighan, Brian W. and Ritchie, Dennis M., The C Programming Language,
       Prentice Hall, 1988.

Solaris 11.4                      9 Oct 2007                         msgcpp(1)