开发者

MinGW 4.5.2 - Problem with initializing member arrays

Initializer lists should be supported since gcc 4.4 (and I could also use them in other places without problems), yet when I try to compile this with MinGW 4.5.2 I开发者_开发百科 get a "bad array initializer" error. I do compile with -std=c++0x. "points" is just a Vector2D[4].

What am I doing wrong?

BoundingBox::BoundingBox(float width, float height, float posX, float posY) :
points{
          Vector2D{posX,posY},
          Vector2D{posX+width, posY},
          Vector2D{posX+width, posY+height},
          Vector2D{posX, posY+height}
    } //error: bad array initializer
{

}


Try adding parens:

points({Vector2D{posX, posY}, ...})

instead of

points{Vector2D{posX, posY}, ...}

I don't have a compiler at hand to check it.


Your code compiles with gcc 4.6.1 (linux).

So if there was a bug it has been fixed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜