• Advertisement
Sign in to follow this  

[SDL] Setting SDL_Color = syntax error

This topic is 3785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement