 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Matthew D Moss Guest
|
Posted: Fri Aug 18, 2006 4:54 am Post subject: POD initialization, standard or extension? |
|
|
Looking among some sample code, I found the following (names changed to
protect the innocent):
struct InitOptions
{
GLuint flags;
GLuint maxItems;
GLboolean initializeItems;
GLuint memorySize;
};
InitOptions opts =
{
flags: FLAG_A | FLAG_B,
maxItems: 1,
initializeItems: false,
memorySize: 128 * 1024 * 1024,
};
I've never seen structure initialization like that... Is this standard,
or a compiler extension?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Jiang Guest
|
Posted: Fri Aug 18, 2006 6:35 am Post subject: Re: POD initialization, standard or extension? |
|
|
Matthew D Moss wrote:
| Quote: | Looking among some sample code, I found the following (names changed to
protect the innocent):
struct InitOptions
{
GLuint flags;
GLuint maxItems;
GLboolean initializeItems;
GLuint memorySize;
};
InitOptions opts =
{
flags: FLAG_A | FLAG_B,
maxItems: 1,
initializeItems: false,
memorySize: 128 * 1024 * 1024,
};
I've never seen structure initialization like that... Is this standard,
or a compiler extension?
|
Designated Initializer is gcc extension.
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Designated-Inits.html#Designated
-Inits
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Ulrich Eckhardt Guest
|
Posted: Fri Aug 18, 2006 6:01 pm Post subject: Re: POD initialization, standard or extension? |
|
|
Matthew D Moss wrote:
| Quote: | struct InitOptions
{
GLuint flags;
GLuint maxItems;
GLboolean initializeItems;
GLuint memorySize;
};
InitOptions opts =
{
flags: FLAG_A | FLAG_B,
maxItems: 1,
initializeItems: false,
memorySize: 128 * 1024 * 1024,
};
I've never seen structure initialization like that... Is this standard,
or a compiler extension?
|
This in particular is a GCC extension. "like that" is standard, although
not C++ standard - it is part of C99 and is done slightly different (and
GCC supports that now, too):
InitOptions opts =
{
.flags = FLAG_A|FLAG_B,
.maxItems = 1,
.initializeItems = false,
.memorySize = 128 * 1024 * 1024,
};
On a side notice, C99 also added support for similar things with arrays:
int arr[20] = { [5]=1, [8]=6, [13]=7 };
Uli
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|