Go to the first, previous, next, last section, table of contents.


Testing macro definitions

There are two different builtin conditionals in m4. The first is ifdef:

ifdef(name, string-1, opt string-2)

which makes it possible to test whether a macro is defined or not. If name is defined as a macro, ifdef expands to string-1, otherwise to string-2. If string-2 is omitted, it is taken to be the empty string (according to the normal rules).

ifdef(`foo', ``foo' is defined', ``foo' is not defined')
=>foo is not defined
define(`foo', `')
=>
ifdef(`foo', ``foo' is defined', ``foo' is not defined')
=>foo is defined

The macro ifdef is recognized only with parameters.


Go to the first, previous, next, last section, table of contents.