当宏以与宏后面的字符串相同的字符结尾时,使m4看到宏 [英] make m4 see macro when macro ends with same character as string following macro
问题描述
我正在使用M4扩展某些文件的系统上工作,但是在某些情况下扩展遇到问题.定义/宏命名的约定(如果可能,我宁愿不要更改)为__<name>__
(即,双下划线和下划线.)因此,此扩展正确:
I'm working on a system that uses M4 to expand some files out, but I'm getting a problem with the expansion in certain cases. The convention for definition / macro naming (which I'd rather not change if possible) is __<name>__
(i.e. double leading and trailing underscores.) So this expands correctly:
define(`__ROOT__', `/home/mydir')
...
__ROOT__/bin
给予
/home/mydir/bin
但是
define(`__PREFIX__', `App_Mnemonic')
...
__PREFIX___some_service
应给出:
App_Mnemonic_some_service
但是给出
__PREFIX___some_service
(即它错过了扩展)
我认为宏的尾部下划线与基础文本的有效下划线之间缺少空格会使m4感到困惑.有什么我可以做的吗?我是否可以使用无声括号来分隔宏,例如环境变量?
I presume the lack of space between the trailing underscore of the macro and the valid underscore of the underlying text is confusing m4. Is there anything I can do about this? Can I delimit the macro with silent braces, for example, like enviromnment variables?
推荐答案
看似简单,我在底层文本中要做的就是更改此内容:
Deceptively simple really, all I had to do in the underlying text was change this:
__PREFIX___some_service
为此:
__PREFIX__()_some_service
也许看起来有些笨拙,但是毕竟它是一个宏,不需要更改宏定义.因此,可以保持原样:
It looks a bit clunky perhaps, but it is a macro after all and there's no need to change the macro definition. So this can stay as it is:
define(`__PREFIX__', `App_Mnemonic')
这篇关于当宏以与宏后面的字符串相同的字符结尾时,使m4看到宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!