I have built a system which has a struct containing other structs, and several macros to initialize them with default values.
Initially the macros would fill the structs sequentially like this:
#define ACM_IIRFILT_DEFAULT_INIT_FOR_INCLUSION(_filterStatePtr, _filterStatePtrStage2) \
{\
ACM_MODULE_INIT_PARTIAL( ACM_IIRFiltRenderFunction,\
ACM_IIRFiltBypassFunction, ACMModuleRenderer, 1, \
ACM_IIRFiltBypassFunction,NCHANNELS, NCHANNELS),\
(void *)_filterStatePtr,\
(void *)_filterStatePtrStage2,\
}\
Note: ACM_MODULE_INIT_PARTIAL is another macro for a struct contained in the first struct.
This worked fairly well, but as some of my structs grew large, I had trouble keeping all macro's in sync with the actual struct declarations,
and debugging errors in these macro's were difficult.
So I started using designated initializers, like in the rewritten example below:
#define ACM_IIRFILT_DEFAULT_INIT_FOR_INCLUSION(_filterStatePtr, _filterStatePtrStage2) \
{\
.Module = ACM_MODULE_INIT_PARTIAL( ACM_IIRFiltRenderFunction,\
ACM_IIRFiltBypassFunction, ACMModuleRenderer, 1, \
ACM_IIRFiltBypassFunction,NCHANNELS, NCHANNELS),\
.iir_states = (void *)_filterStatePtr,\
.iir_statesStage2 = (void *)_filterStatePtrStage2,\
}\
And in order to further ensure that all members of my large structs were properly initialized I started using the pragma above (in the headline).
But in one case, I kept getting a diagnostic error for the initialization of one of these structs, and since all contained structs had the same macro I know almost for sure that none of those are partially initialized.
Still I get the error for the large struct, that it is being partially initialized.
I ended up for now with removing the pragma because I was almost sure the struct _is_ fully initialized, and needed to continue work elsewhere.
So my question is:
Does anyone know have any suggestions to what I could try to do to resolve this properly ?
Thanks
/Lars