Re: defn(`a b'): is it standard or extension? Is it reliable?
Eric Blake <[email protected]> Wed, 4 Feb 2026 10:17:44 -0600
| Newsgroups | gmane.comp.gnu.m4.general |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Feb 02, 2026 at 01:52:07PM -0600, Eric Blake wrote: > In practice, I've tested with BSD m4, which behaves almost like GNU m4 > in allowing arbitrary strings to be defined as a macro, and then later > retrieved using defn, ifdef, or dumpdef, but with one caveat - BSD m4 > will not support the empty string as a macro name, even though GNU m4 > has no problem with that. But beyond that, I can't definitively state > whether there are other implementations of m4 that will choke on > attempting to define an atypical macro name. As a postscript not quite related your original question: Today I noticed that in GNU m4, defn(`a', `b') produces the contents of `a' first, then `b'; but BSD m4 produces the contents of `b' first, then `a'. So portable scripts should consider using defn(`a')defn(`b') rather than getting defn() itself to do concatenation, even though my read of POSIX says the GNU interpretation is desired. -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org