[SDL] Setting SDL_Color = syntax error

Started by
1 comment, last by Obbedemus 16 years, 6 months ago
I have a class which contains the variable SDL_Color textColor. In the constructor I write textColor = {0, 0, 0} to set the color but when I do, I end up with these error messages: error C2059: syntax error : '{' error C2143: syntax error : missing ';' before '{' error C2143: syntax error : missing ';' before '}' I've checked and checked again and all the { and } are there. Does anyone know what might be the mistake I've done? I have a lot of things to see if they work so a quick reply is much appriated! Thanks in advance!
( /)(O.o)(> <)This is Bunny. Copy him into your signature to help him on his way to world domination.
Advertisement
Quote:Original post by Obbedemus
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
error C2143: syntax error : missing ';' before '}'

I've checked and checked again and all the { and } are there.

The compiler is telling you that the braces shouldn't be there. You can't set the coordinates of an SDL_Color via assignment using the brace notation. That only works in an initialization. Yes, I know. C and C++ are annoying that way.

You're going to have to do this:
textColor = r = 0;textColor.g = 0;textColor.b = 0;
Ah, thank you! That makes perfectly sense! (Or not sense, depending on how you see it)
( /)(O.o)(> <)This is Bunny. Copy him into your signature to help him on his way to world domination.

This topic is closed to new replies.

Advertisement