c++ problem

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
I posted the relevant code below. Here's the line that has a problem:

...
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);

if ((ISPRESSED_PLAY_BUTTON(xPos,yPos)) && (PLAY_BUTTON_STATE==2)) {

If in place of ==2, I put ==BUTTON_CLICKED, it yields a bunch of errors:

MPlayer.cpp(270): error C2143: syntax error : missing ')' before ';'
MPlayer.cpp(270): error C2143: syntax error : missing ')' before ';'
MPlayer.cpp(270): error C2059: syntax error : ')'
MPlayer.cpp(270): error C2059: syntax error : ')'
MPlayer.cpp(270): warning C4390: ';' : empty controlled statement found; is this the intent?

Why? BUTTON_CLICKED is equal to 2, so it should be just fine, right? Just putting 2, it will compile and my program works just as expected. It would be nice if I could use the BUTTON_CLICKED name instead of 2, though, so I know what's going on. Is using a BYTE type wrong for this purpose? I just need a couple of states, and since a byte has 256 states, I thought it would be perfectly adequate versus some of the bigger short and integer types.

It doesn't work this way either:

if (PLAY_BUTTON_STATE==BUTTON_CLICKED)
 

bsobel

Moderator Emeritus<br>Elite Member
Dec 9, 2001
13,346
0
0
c++ #define statement is literal. You said:

#define BUTON_CLICKED 2;

The extra ; is literally inserted into your code be the preprocessor (think of it as search and replace) so change it to:

#define BUTTON_CLICKED 2
 

itachi

Senior member
Aug 17, 2004
390
0
0
it doesn't really help to post up your problematc code.. and not even include the area of code where the error is detected.

either way.. your problem is with your preprocessor definitions.

#define BUTTON_NONE 0;
defines a symbol BUTTON_NONE as '0;'. so wherever BUTTON_NONE is found, 0; is placed there.

#define BUTTON_NONE 0
#define BUTTON_HOVER 1
#define BUTTON_CLICKED 2
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Whoops, good catch. ;) Yeah, I posted too much code and it turned out to be a careless error like this. Works now, thanks.