Next: , Up: Miscellaneous   [Contents][Index]


14.1 Printing error messages

You can print error messages using errprint:

Builtin: errprint (message, …)

Prints message and the rest of the arguments to standard error, separated by spaces. Standard error is used, regardless of the --debugfile option (see Invoking m4).

The expansion of errprint is void. The macro errprint is recognized only with parameters.

errprint(`Invalid arguments to forloop
')
error→Invalid arguments to forloop
⇒
errprint(`1')errprint(`2',`3
')
error→12 3
⇒

A trailing newline is not printed automatically, so it should be supplied as part of the argument, as in the example. Unfortunately, the exact output of errprint is not very portable to other m4 implementations: POSIX requires that all arguments be printed, but some implementations of m4 only print the first. Furthermore, some BSD implementations always append a newline for each errprint call, regardless of whether the last argument already had one, and POSIX is silent on whether this is acceptable.