Below is something that did happen to me and I couldn't get wha开发者_StackOverflowt's wrong. My coworker and me screwed our heads around this. It was in a cross-platform library using the cross-platform toolkit wxWidgets on Windows
#include <wx/wx.h>
class Graph {
public:
// ...
// main1.cpp:4:10: error: expected identifier before '(' token
double GetYValue(double x);
};
We were trying hard to find any weird glyph placed instead of an ASCII e
or something, but didn't find any such issue. What was going on!?
WinGDI.h ln 640: #define GetYValue(cmyk) ((BYTE)((cmyk)>> 8))
Gotta love windows.h
This is why I recommend AGAINST using camel case for most things.
I don't use wxWidgets myself, but in http://gambit.sourcearchive.com/documentation/0.2006.01.20/plotctrl_8cpp-source.html I find strange code fragment
#ifdef GetYValue // Visual Studio 7 defines this
#undef GetYValue
#endif
Look at the wxWidgets headers. Probably are there a code fragment like this or you should do something like this?
My first guess would be that <wx/wx.h>
has a macro named GetYValue
(and probably another named GetXValue
) that are supposed to take some sort of combined X/Y value and "unwrap" them into their individual components, on the general order of:
#define GetXValue(xy) ((xy)>>16)
#define GetYValue(xy) ((xy)&x0ff)
With that expanded, your code would look something like:
double ((xy)>>16)(double x);
...at which point the compiler has a hissy fit -- except, of course, that it probably gave up parsing sooner than that, since the double x
appears to be trying pass two tokens as parameters to a macro that only expects 1.
Edit: I see I was guessing fairly close, but guessed wrong about what sort of "Y" was involved here -- the others would apparently be GetCValue
, GetMValue
, etc., instead of GetXValue
. Oh well...
精彩评论