Skip to main content
gamedev.net
🔒 Locked

Weird compiler warning

Started by biscuitz 1 reply 350+ views
Original Post
biscuitz
biscuitz
This code:
RECT Grid[] =
{
  2, 3, 3, 5,
  3, 2, 4, 7
};

Makes the compiler spit out a warning: "Missinge braces around initializer". o.O HUH? The warning only shows up if I turn on "All warnings" setting for compiler (GCC) If I turn off "All warnings" then the warning goes away... also if I get rid of the second line then the warning goes away too. But still, what the heck does it mean "missing braces"?
jpetrie
jpetrie
You're initializing an array of RECTs. The compiler expects: RECT rects[] = { RECT1, RECT2, RECT3, ... }; where each of RECT1, RECT2, et cetera looks like { left, top, bottom, right } (or whatever is appropriate for RECT). In other words:

RECT Grid[] ={  { 2, 3, 3, 5 },  { 3, 2, 4, 7 }};


biscuitz
biscuitz
=D lol that makes sense. And it looks better when it's declared that way. Thanks :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.