views:

18

answers:

1

Hi, I use m4 for a little text preprocessing here, and it behaves in a way I don't understand.

This is the portion in question:

ifdef(`TEST',
    define(`O_EXT', `.obj'),
    define(`O_EXT', `.o'))

This macro will always be expanded to .o, regardless whether TEST is defined (m4 -DTEST) or not.

What am I doing wrong?

A: 

You're not quoting the other arguments to ifdef. Try this:

ifdef(`TEST', `define(`O_EXT', `.obj')', `define(`O_EXT', `.o')')
Jack Kelly