m4 - Preprocesses files, expanding macro definitions
m4 [-Bnumber] [-es] [-Hnumber] [-Snumber] [-Tnumber] [-Dmacro][=value] [-Umacro] file...|-
command is a macro
processor used as a preprocessor for C and other languages.
Interfaces documented on this reference page conform to industry standards as follows:
m4: XPG4, XPG4-UNIX
Refer to the
reference page for more information
about industry standards and associated tags.
[Compaq] Makes number the size of the push-back and parameter collection buffers (the default is 4096). [Compaq] Operates interactively. Interrupts are ignored and the output is not buffered. [Compaq] Makes number the size of the symbol table hash array (the default is 199). The size must be a prime number. [XPG4-UNIX] Enables the line sync output for the C preprocessor (#line...). [Compaq] Makes number the size of the call stack (the default is 800 slots). Macros take three slots, and nonmacro arguments take one. [Compaq] Makes number the size of the token buffer (the default is 512 bytes). [XPG4-UNIX] Defines macro as value. If value is not specified, macro becomes null. [XPG4-UNIX] Undefines a built-in macro or one previously defined with the -D option.
[XPG4-UNIX] The order of options is significant. If used, the -D or -U options must appear after any other options and before any file operands.
[XPG4-UNIX] Pathname of a file to be processed.
is omitted, standard input is used.
[XPG4-UNIX] Read standard input.
[XPG4-UNIX] You can use m4 to process built-in macros or user-defined macros. Each file is processed in order. If you do not specify a file or if you give a dash (-) as a filename, the m4 command reads standard input. It writes the processed macros to standard output.
[XPG4-UNIX] Macro calls follow the form: macro(argument...)
[XPG4-UNIX] The left parenthesis must immediately follow macro. If the left parenthesis does not follow the name of a defined macro, the m4 command reads it as a macro call with no arguments. Macro names consist of ASCII alphabetic letters, digits, and the underscore (_) character. Extended characters are not allowed in macro names. The first character cannot be a digit.
[XPG4-UNIX] While collecting arguments, the m4 command ignores unquoted leading spaces, tabs, and newline characters. Use single quotes ('') to quote strings. The value of a quoted string is the string with the quotation marks stripped off.
[XPG4-UNIX] When the
a macro, it collects arguments by searching for a matching right parenthesis.
If you supply fewer arguments than appear in the macro definition,
considers the trailing arguments in the definition to be null.
Macro evaluation proceeds normally during the collection of the arguments.
All commas or right parentheses within the value of a nested call are translated
literally; they do not need an escape character or quotation marks. After
collecting arguments, the
command pushes the value of
the macro back onto the input stream and scans again.
[XPG4-UNIX] The m4 command contains the following built-in macros. You can redefine them, but they will then lose their original meanings. The values of these macros are null unless otherwise stated: [XPG4-UNIX] Replaces the macro macro with the value of new_name. The new_name string can included tokens of the form $n... (where n is a digit). In this case, each occurrence of $n in the replacement text is replaced by the n-th argument of macro. The name of the macro is $0. The null string replaces missing arguments. The number of arguments replaces $#. A list of all arguments, separated by commas, replaces $*. The $@ acts like $*, but each argument is quoted with the current quotation character (see the changequote macro). [XPG4-UNIX] Removes the definition of macro (including those preserved using the pushdef macro). [XPG4-UNIX] Returns the quoted definition of macro. [XPG4-UNIX] If the first argument is defined, the value is the second argument. Otherwise, the value is the third argument. If there is no third argument, the value is null.
[XPG4-UNIX] Successful completion. [XPG4-UNIX] An error occurred.
[XPG4-UNIX] If you use the
macro, the input file can specify the exit value.
To preprocess a C language program with m4 and compile it, enter: m4 prog.m4 >prog.c cc prog.c
The following environment variables affect the execution of
[XPG4-UNIX] Provides a default value for the
internationalization variables that are unset or null. If
is unset or null, the corresponding value from the default
locale is used. If any of the internationalization variables contain an invalid
setting, the utility behaves as if none of the variables had been defined.
[XPG4-UNIX] If set to a non-empty string value,
overrides the values of all the other internationalization variables.
[XPG4-UNIX] Determines the locale for the
interpretation of sequences of bytes of text data as characters (for example,
single-byte as opposed to multi-byte characters in arguments).
[XPG4-UNIX] Determines the locale for the
format and contents of diagnostic messages written to standard error.
[XPG4-UNIX] Determines the location of message
catalogues for the processing of
Commands: c89(1), cc(1), cpp(1)