Strange error to declare member function

Below something happened to me, and I could not understand what happened. My colleague and I screwed my head. This was in a cross-platform library using the wxWidgets cross-platform toolkit on Windows

#include <wx/wx.h> 

class Graph {
public:
  // ...
  // main1.cpp:4:10: error: expected identifier before '(' token
  double GetYValue(double x);
};

We tried to find some strange glyph instead of ASCII eor something else, but we did not find such a problem. What's happening!?

+3
source share
3 answers

WinGDI.h ln 640: #define GetYValue(cmyk) ((BYTE)((cmyk)>> 8))

Must love windows.h

That's why I recommend AGAINST using a camel case for most things.

+9
source

wxWidgets , http://gambit.sourcearchive.com/documentation/0.2006.01.20/plotctrl_8cpp-source.html

#ifdef GetYValue   // Visual Studio 7 defines this
    #undef GetYValue
#endif

wxWidgets. , , , - ?

+7

, <wx/wx.h> GetYValue (, , GetXValue), - X/Y "" , :

#define GetXValue(xy) ((xy)>>16)
#define GetYValue(xy) ((xy)&x0ff)

, :

double ((xy)>>16)(double x);

... - , , , , , , double x, , , 1.

Edit: I see that I was guessing pretty closely, but I was guessing incorrectly that “Y” was participating in it - the others, apparently, would be GetCValue, GetMValueetc. instead of GetXValue. Oh good...

+6
source

Source: https://habr.com/ru/post/1761185/


All Articles