[Top][All Lists]
[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 21:08:21 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Mehul Sanghvi <mehul.sanghvi <at> gmail.com> writes:
> In case this is the wrong place for sending this question, please
> point me in the correct direction.
This is the correct place.
> testing.m4
> ========
> define('VNC')
Incorrect quotes. By default, m4 uses "`" and "'", not "'" and "'".
Therefore, you ended up defining a macro literally named "'VNC'", rather than
the intended "VNC".
> 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'>, ..., ...)
and since the expansion of "'VNC'" was defined as the empty string, you are
testing whether the empty string is currently defined as a macro name. It
isn't, hence your surprise.
>
> 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.
>
> Am I missing something or have I misunderstood what the manual says
> about how to use ifdef and -D ?
You misunderstood the portion about quoting characters. Let us know if there
is any way to improve the manual to make it more obvious that they are
intentionally distinct strings.
--
Eric Blake
- ifdef usage, Mehul Sanghvi, 2009/04/21
- Re: ifdef usage,
Eric Blake <=