[SDL] Setting SDL_Color = syntax error
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!
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;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement