编译时添加的奇怪字符会导致错误

Strange character added while compilation, leads to an error

本文关键字:错误 字符 添加 编译      更新时间:2023-10-16

当用Visual Studio Express 2013编译项目时,我得到这个错误

....WDLIPlugIPlugVST3.cpp(199):错误C2065: 'Lp':未声明的标识符[D: WDL -olIPlugExamplesMyFirstPluginMyFirstPlugin-vst3.vcxproj]

奇怪的是文件IPlugVST3.cpp不包含Lp而只包含p:

 switch (p->Type())
  {
    case IParam::kTypeDouble:
    case IParam::kTypeInt:
    {
      Parameter* param = new RangeParameter( STR16(p->GetNameForHost()), // <---- this line
                                             i,
                                             STR16(p->GetLabelForHost()),
                                             p->GetMin(),
                                             p->GetMax(),
                                             p->GetDefault(),
                                             0, // continuous
                                             flags,
                                             unitID);
      param->setPrecision (p->GetPrecision());
      parameters.addParameter(param);

为什么c++编译器把它理解为Lp而不是p ?

注意:我检查了是否没有隐藏的unicode字符(这存在吗?)但是没有…

STR16很可能是一个需要字符串作为参数的宏,例如

#define STR16(s) L##s

或类似的东西。如果你传递一个变量而不是字符串字面值,那么你会得到类似于你正在观察的问题。