m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ifdef usage


From: Eric Blake
Subject: Re: ifdef usage
Date: Tue, 21 Apr 2009 22:08:43 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

Aargh.  I typed my first answer too hastily.

> Incorrect quotes.  By default, m4 uses "`" and "'", not "'" and "'".  
> Therefore, you ended up defining a macro literally named "'VNC'", rather than 
> the intended "VNC".

This part still stands.

> 
> >    ifdef('VNC', 'vnc is DEFINED', 'vnc is NOT DEFINED')
> 
> M4 performs macro expansion during argument collection.  Since you aren't 
using 
> proper quote characters, this means that you effectively called:
> 
> ifdef(<expansion of 'VNC'>, ..., ...)

Correction.  ' is not part of a macro name, so you effectively called:

ifdef("'"<expansion of VNC>"'", ..., ...)

But since VNC is not a macro, that means you are checking the result of 
whether "'" concatenated with "VNC" concatenated with "'" is a macro, and 
indeed, "'VNC'" is a macro.

> > If I comment out the define(), and then do the following:
> > 
> >    bash% m4 -DVNC testing.m4
> >    #define('VNC')
> >    'vnc is NOT DEFINED'
> 
> Your command-line usage defined the macro "VNC", as you wanted.  Now 
> that "'VNC'" is not a macro, your ifdef usage is checking whether "'VNC'" is 
> defined, which it is not, still explaining your surprise.

Correction.  Here, "VNC" is a macro, which means you are checking whether "'" 
concatenated with its expansion ("") concatenated with "'" is a macro, and 
since "''" is not a macro, that explains your result.

-- 
Eric Blake







reply via email to

[Prev in Thread] Current Thread [Next in Thread]