gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > warning: aggregate has a partly bracketed initializer

#13689 - gb_feedback - Sat Dec 20, 2003 7:10 pm

I have a piece of c++ code (which works ok) looking something like the following:
Code:
void CExpand::ExpandData()
{
   struct Decode
   {
       int   base;
       int   extBits;
   };
   Decode lengthTable[] =
   {
      3, 0,
      4, 0,
      5, 0,
      6, 0,
      7, 0,
      ... ...
      256, 0
   };
etc....


Every line of the table reports:
main.cpp:4544: warning: aggregate has a partly bracketed initializer

Can a C++ guru indicate the error I am making against the spirit of C++ which gives me this warning but doesn't stop the program working?
_________________
http://www.bookreader.co.uk/

#13690 - DiscoStew - Sat Dec 20, 2003 7:24 pm

Because you are making an array of a structure, you will need to separate your array out so that the things of a structure are grouped together. With what you have, try setting up your array like so...

Code:

Decode lengthTable[] = {
  {3, 0},
  {4, 0},
  {5, 0},
  .........
  {256, 0}
};


See if that works...
_________________
DS - It's all about DiscoStew

#13717 - gb_feedback - Sun Dec 21, 2003 10:29 am

Brilliant! That's 59 warnings got rid of. Thanks!
_________________
http://www.bookreader.co.uk/