Nested structures in headers and C++ compatibility?

Joel Sherrill joel.sherrill at oarcorp.com
Thu Oct 16 13:57:14 UTC 2014


On 10/16/2014 5:58 AM, Sebastian Huber wrote:
> On 16/10/14 12:42, Peter Dufault wrote:
>> The only hack I have is to re-define the typedef to scope the type:
>>
>> typedef struct {
>>    uint32_t index : 10;
>>    uint32_t count : 10;
>>    uint32_t output : 1;
>> #ifdef __cplusplus
>>    union SIU_tag::SIU_PCR_tag pcr;
>> #else
>>    union SIU_PCR_tag pcr;
>> #endif
>> } mpc55xx_siu_pcr_config;
> This is fine for me.
>
The only alternative I see is to define a more obscure type
name based on C/C++ and define SIU_PCR_tag as a macro
which expanded to the correct form. If this type has reason
to be used anywhere else, this might be preferred.

But if this is the only place the type is every likely to be used,
I am OK with this.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the users mailing list