m4-discuss
[Top][All Lists]
Advanced

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

Re: Help on M4 Usage


From: Eric Blake
Subject: Re: Help on M4 Usage
Date: Fri, 29 Apr 2016 09:46:45 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

[top-posting on technical lists makes it harder to follow the conversation]

On 04/29/2016 09:17 AM, Nidhin Joseph wrote:
> Hi,
>  Yes. I understand your point. But I would like to clear one more doubt. Is
> it possible to prevent macro expansion if the key is quoted?
> 
> For example,
>   - getApproximateValue(MY_CUSTOM_KEY) should be converted to
> getApproximateValue(50)
>   - getApproximateValue("MY_CUSTOM_KEY") should remain as
> getApproximateValue("MY_CUSTOM_KEY")

The only way to make M4 not do macro expansion is to use m4 quotes; if
your source file uses

getApproximateValue(`"MY_CUSTOM_KEY"')

(assuming you didn't use changequote() to change the m4 quoting to
something else), then the expansion will be:

getApproximateValue("MY_CUSTOM_KEY")

regardless of whether MY_CUSTOM_KEY is a macro.  But unlike the C
preprocessor, m4 does not have a way to identify C strings where macros
are not to be expanded.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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