m4(1)

m4(1)

NAME

m4 - macro processor

SYNOPSIS

m4 [options] [®le ...]

DESCRIPTION

m4 is a macro processor intended as a front end for Ratfor, C, and other languages. Each of the argument ®les is processed in order; if there are no ®les, or if a ®le name is -, standard input is read. The processed text is written to standard output.

Options

m4 recognizes the following options:

-e

Operate interactively. Interrupts are ignored and the output is unbuffered. Using this

 

mode may be very dif®cult.

-s

Enable line sync output for the C preprocessor (#line ...)

-Bint

Change the size of the push-back and argument collection buffers from the default of 4,096.

-Hint

Change the size of the symbol table hash array from the default of 199. The size should be

 

prime.

-Sint

Change the size of the call stack from the default of 100 slots. Macros take three slots, and

 

nonmacro arguments take one.

-Tint

Change the size of the token buffer from the default of 512 bytes.

To be effective, the options listed above must appear before any ®le names and before any -Dor -Uoptions.

-Dname[=val]

De®ne name as val or as null if val is omitted.

-Uname Unde®ne name.

Macro Calls

Macro calls have the form:

name(arg1, arg2, ... ,argn)

The left parenthesis (() must immediately follow the name of the macro. If the name of a de®ned macro is not followed by a (, it is deemed to be a call of that macro with no arguments. Potential macro names consist of alphabetic letters, digits, and underscore (_); the ®rst character cannot be a digit.

Leading unquoted blanks, tabs, and newlines are ignored while collecting arguments. Left and right single quotes (` and ') are used to quote strings. The value of a quoted string is the string stripped of the quotes.

When a macro name is recognized, its arguments are collected by searching for a matching right parenthesis. If fewer arguments are supplied than are in the macro de®nition, the trailing arguments are taken to be null. Macro evaluation proceeds normally during the collection of the arguments, and any commas or right parentheses which happen to turn up within the value of a nested call are as effective as those in the original input text. After argument collection, the value of the macro is pushed back onto the input stream and rescanned.

Built-In Macro Names

m4 makes available the following built-in macros. They can be rede®ned, but, once this is done, the original meaning is lost. Their values are null unless otherwise stated.

changecom Change left and right comment markers from the default # and newline. With no argu- ments, the comment mechanism is effectively disabled. With one argument, the left marker becomes the argument and the right marker becomes newline. With two argu- ments, both markers are affected. Comment markers may be up to ®ve characters long.

changequote Change quote symbols to the ®rst and second arguments. The symbols may be up to ®ve characters long. changequote without arguments restores the original values (i.e., ` and ').

m

HP-UX Release 11i: December 2000

− 1 −

Section 1485