home | tech | misc | code | bookmarks (broken) | contact | README


M4 notes

Troubleshooting

Error m4: unexpected end of input, unclsed parenthesis or ERROR: end of file in argument list

I got this error when trying to pre-process the following file with the M4 preprocessor:

define(`rgb', ifelse(color, `white', `#ffffff', `#000000'))dnl
RGB: rgb

In NetBSD the error is:

m4: unexpected end of input, unclosed parenthesis:

In GNU/Linux, it is:

m4:m4:1: ERROR: end of file in argument list

After some research I discovered that the '#' character can be used as a comment character. m4 don't process stuff everything after this, although it still echoes that to the output (differently from dnl). The strange thing is that this rule seem to be valid inside quotes too.

So, in order to make it work, you have to add another level of quoting:

define(`rgb', ifelse(color, `white', ``#'ffffff', ``#'000000'))dnl
RGB: rgb

Now it seems to work :-)

Thanks to the great Notes on the M4 Macro Language page with lots of nice information about M4!

Also, this link recommends using the changecom() function to change comments: