manpagez: man pages & more
info m4
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1 Testing if a macro is defined

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

Builtin: ifdef (name, string-1, [string-2]

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).

The macro ifdef is recognized only with parameters.

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
ifdef(`no_such_macro', `yes', `no', `extra argument')
error-->m4:stdin:4: Warning: excess arguments to builtin `ifdef' ignored

This document was generated on September 29, 2013 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.