How to resolve warning 'excess arguments to builtin `define' ignored' with m4

334 views Asked by At

I'm using m4 define to create a macro. I tried using include(file) to read the content of the file as below.

 define(`TEST', include(file1))
 TEST

file1:

test -abc -LDFLAGS "-Wl,-rpath,/home/user -lmsg"

When I run the code, it gives a warning and doesn't print anything beyond -Wl

    m4:r1:1: Warning: excess arguments to builtin `define' ignored

    test -abc -LDFLAGS "-Wl 

I tried using single quotes, but it didn't work. Can someone please help me resolve this?

1

There are 1 answers

0
markasoftware On

If there are commas in the file, those will be interpreted as argument separators. The include replacement is inserted before determining the arguments to define.

Using single quotes is correct -- then the include will be processed in the output instead. For example:

define(`TEST', `include(file1)')
TEST

does work on my machine. (note that an even better solution is to add quotes around file1 as well).