开发者

How to print #(sharp sign) in a Makefile

开发者 https://www.devze.com 2023-03-14 20:38 出处:网络
Suppose you have a variable which is set as: AVar = \"#\" echo \"${AVar}\" The above thing does not outp开发者_开发技巧ut in Makefile when run through make.

Suppose you have a variable which is set as:

AVar = "#"

echo "${AVar}"

The above thing does not outp开发者_开发技巧ut in Makefile when run through make.

# must be escaped but the AVar may not have special chars in its content?

So what can I escape the Avar?


Tested working with GNU Make 3.81 on MacOS X:

AVar = "\#"

foo:
    @echo "${AVar}"

I'm not sure what you mean by "AVar may not have special chars in its content". In this case it's the only way to tell make that the # is part of the string, and not the start of a comment.

0

精彩评论

暂无评论...
验证码 换一张
取 消