I have defined a function not in class
#define BlendLight(b1, b2) std::max(b1, b2)
then in the class I am trying to use it:
float someFunk(float x, float y)
{
return BlendLight(x,y); //Error here - BlendLight marked red (
}
And I get Error: Expected an identifier
I am try to compile this in Visual Studio 2010
std::max() header is included / I have add algorithm but error still present (((
The code isn’t erroneous as it stands. Most likely you have forgotten to
This is the header file where
std::maxis defined.Another possibility is that you didn’t define
BlendLightin the same file as the class where you want to use it. In that case you have to#includethe header file whereBlendLightis defined.Apart from this, you should know that what you have defined is not a function, but a preprocessor macro. In C++, you should rather use a proper (maybe
inline) function for this task, so that your compiler can do type checking: