vcast工具env环境问题二:<command-line>: error: stray â\â in program
宏转义字符问题
错误信息:
<command-line>: error: stray ‘\’ in program
<command-line>: error: stray ‘\’ in program
<command-line>: error: ‘develop’ was not declared in this scope
<command-line>: error: unable to find numeric literal operator ‘operator""be2999b0118dac0578d85a5e9d5’
因为一些宏使用的是字符串,出现这个信息说明是某些转义字符出问题了,例如**“/ \"**等
解决方法:
1.在脚本里面使用sed命令替换斜杠。
sed 's/\\/\\\\/g' filename
2.在脚本里面使用awk精准替换转义字符。
awk '{gsub(/\\"/,"\\\\\"")}1' filename
3.在代码里面修改,把用到这个宏的地方修改,可用于临时验证,不推荐此方法。
#define HONG "develop\\f3f1fbe70afc41a8015c292"