描述:
我的GNU生成文件中有以下片段:
test:=$(shell grep '#pragma' test_types.h)
$(info test:$(test))
以上结果导致以下错误消息:
***对函数"shell"的未终止调用:缺少"("。停止
但是,如果我从上面的代码段中删除"#">:
test:=$(shell grep 'pragma' test_types.h)
$(info test:$(test))
输出为:
测试:#pragma pack(push,1(#pragmapack(pop(
如果我直接从命令行运行以下命令:grep '#pragma' test_types.h
。输出再次为:
#pragma pack(push,1(#pragma pack(pop(
问题:
当grep与GNU makefile中的#
搜索相结合时,shell函数行为的原因是什么?
它将#
解释为注释的开头,因此该行的其余部分不再可见。
将字符转义为#
,它将起作用。