对于 C 头文件,您可以防止包含多个头文件,例如:
#ifndef MY_FOO_H
#define MY_FOO_H
[...]
#endif
如何在 m4 中做同样的事情,include()
以便对同一文件的多个宏调用只会导致内容被包含一次?
具体来说,我想做一个涉及使用宏的 ifdef 保护changequote
(我不会用dnl
's 弄乱我的代码):
最初,当我执行以下操作时,多个包含仍然会破坏引号:
更改quote_file.m4:
ifdef(my_foo_m4,,define(my_foo_m4,1)
changequote([,])
)
更改quote_invocation.m4:
include(changequote_file.m4)
After first include invocation:
[I should not have brackets around me]
`I should have normal m4 quotes around me'
include(changequote_file.m4)
After second include invocation:
[I should not have brackets around me]
`I should have normal m4 quotes around me'
m4 changequote_invocation.m4
使用产量调用:
After first include invocation:
I should not have brackets around me
`I should have normal m4 quotes around me'
After second include invocation:
[I should not have brackets around me]
`I should have normal m4 quotes around me'