Basj Basj - 2 months ago 24
C++ Question

Strange character added while compilation, leads to an error

When compiling a project with Visual Studio Express 2013, I get this error


....\WDL\IPlug\IPlugVST3.cpp(199): error C2065: 'Lp' : undeclared identifier [D:\wdl-ol\IPlugExamples\MyFirstPlugin\MyFirstPlugin-vst3.vcxproj]


The strange thing is that the file
IPlugVST3.cpp
doesn't contain
Lp
but only
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);


Why does the C++ compiler understands it a
Lp
instead of
p
?


Note: I checked if there are no hidden unicode characters (does this exist?) but no...

Answer

STR16 is most likely a macro which expects a string literal as an argument, e.g.

#define STR16(s) L##s

or something similar. It you pass a variable instead of a string literal then you will get something like the problem you are observing.

Comments