Johannes Bauer
2010-07-29 16:57:58 UTC
Hello group,
I know this might be an implementation detail - however I do not
understand why the languages C++ and C are different in the following
example - I'm quite stunned and am looking for an explanation. Writing
some code and porting from C to C++ I encountered the error "sorry,
unimplemented: non-trivial designated initializers not supported" from
g++ 4.3.4. I boiled it down to a minimal example which compiles fine
under C, but emits that error message when compiled under C++:
typedef void (*FunctionType)(void);
typedef struct PODObject {
void *PointerValue;
FunctionType FunctionValue;
} PODObject;
void MyFunctionImpl(void);
PODObject vectorTable = {
FunctionValue: MyFunctionImpl,
};
void MyFunctionImpl() {
}
I have three options to make the code compile even when using C++:
1. Comment out the void* declaration of the PODObject
2. Change the order or PointerValue and FunctionValue
3. Define PointerValue in the struct definition
However, none of these options are really applicable in this particular
case. Is there a possibility or workaround or completely different
approach which lets me do the same thing as C does (i.e. fill the
undefined struct values with some random undefined data)?
Regards,
Johannes
I know this might be an implementation detail - however I do not
understand why the languages C++ and C are different in the following
example - I'm quite stunned and am looking for an explanation. Writing
some code and porting from C to C++ I encountered the error "sorry,
unimplemented: non-trivial designated initializers not supported" from
g++ 4.3.4. I boiled it down to a minimal example which compiles fine
under C, but emits that error message when compiled under C++:
typedef void (*FunctionType)(void);
typedef struct PODObject {
void *PointerValue;
FunctionType FunctionValue;
} PODObject;
void MyFunctionImpl(void);
PODObject vectorTable = {
FunctionValue: MyFunctionImpl,
};
void MyFunctionImpl() {
}
I have three options to make the code compile even when using C++:
1. Comment out the void* declaration of the PODObject
2. Change the order or PointerValue and FunctionValue
3. Define PointerValue in the struct definition
However, none of these options are really applicable in this particular
case. Is there a possibility or workaround or completely different
approach which lets me do the same thing as C does (i.e. fill the
undefined struct values with some random undefined data)?
Regards,
Johannes
--
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$***@speranza.aioe.org>
Wo hattest Du das Beben nochmal GENAU vorhergesagt?
Zumindest nicht öffentlich!Kosmologen: Die Geheim-Vorhersage.
- Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$***@speranza.aioe.org>