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

8.1 Deleting whitespace in input

The builtin dnl stands for “Discard to Next Line”:

Builtin: dnl

All characters, up to and including the next newline, are discarded without performing any macro expansion. A warning is issued if the end of the file is encountered without a newline.

The expansion of dnl is void.

It is often used in connection with define, to remove the newline that follows the call to define. Thus

define(`foo', `Macro `foo'.')dnl A very simple macro, indeed.
foo
⇒Macro foo.

The input up to and including the next newline is discarded, as opposed to the way comments are treated (see section Comments in m4 input).

Usually, dnl is immediately followed by an end of line or some other whitespace. GNU m4 will produce a warning diagnostic if dnl is followed by an open parenthesis. In this case, dnl will collect and process all arguments, looking for a matching close parenthesis. All predictable side effects resulting from this collection will take place. dnl will return no output. The input following the matching close parenthesis up to and including the next newline, on whatever line containing it, will still be discarded.

dnl(`args are ignored, but side effects occur',
define(`foo', `like this')) while this text is ignored: undefine(`foo')
error-->m4:stdin:1: Warning: excess arguments to builtin `dnl' ignored
See how `foo' was defined, foo?
⇒See how foo was defined, like this?

If the end of file is encountered without a newline character, a warning is issued and dnl stops consuming input.

m4wrap(`m4wrap(`2 hi
')0 hi dnl 1 hi')
⇒
define(`hi', `HI')
⇒
^D
error-->m4:stdin:1: Warning: end of file treated as newline
⇒0 HI 2 HI

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.