Menu

#17 struct initializer with condition

Moritz_2_0_1
closed
None
3
2021-09-22
2020-12-28
No

Hi Eckard,

when using 'designated initializers' combined with preprocessor conditions it fails.

typedef struct
{
    union
    {
        struct
        {
            uint32_t        u1first  : 1;        
            uint32_t        u1second : 1;        
            uint32_t        u30rest  : 30;
        };
        uint32_t            u32Result;
    };
} myUnnamedBitFields_t;

int test(void){
  myUnnamedBitFields_t bf = (myUnnamedBitFields_t){
    .u1first  = 0,
#if TEST
    .u1second = 1,
#endif
    .u30rest  = 2
  }

  return 0;
}

BR
Wasili

Discussion

  • Wasilios Goutas

    Wasilios Goutas - 2020-12-28

    reproduser attached

     
  • Eckard Klotz

    Eckard Klotz - 2020-12-28

    Hello Wasili.

    To solve this issue I have to provide new configuration files. This patch should should solve your issue "struct initializer with condition ".

    • Please check the attached files with your virus scanner before you use it to replace the one with the same name in the bin folder of your Moritz distribution.

    • Replace with the attached file "ANSI_C_Source_C_only_grm.a2x" the one with the same name in your Moritz distribution sub folder "[MoritzRoot]\LangPack\ansi_c\a2x\".

    • Replace with the attached file "nsd_ansi_c_cfg.x2a" the one with the same name in your Moritz distribution sub folder "[MoritzRoot]\LangPack\ansi_c\x2a_nsd\".

    • Replace with the attached file "uad_ansi_c_cfg.x2a" the one with the same name in your Moritz distribution sub folder "[MoritzRoot]\LangPack\ansi_c\x2a_uad\".

    • It may be useful to keep the old files for the case that the new ones are not satisfying you.

    Note this patch was created for the newest Moritz patch published on 2020-12-23 and was not tested with older versions.

    If the patch is not working with your older version, please update and apply the patch there also.

    Check the patch and respond with a comment if your issue is solved or not.

    I wish you a happy new year.

    Stay healthy,
    Eckard.

     
  • Eckard Klotz

    Eckard Klotz - 2020-12-28
    • status: open --> pending
     
  • Wasilios Goutas

    Wasilios Goutas - 2020-12-29

    Hello Eckard,

    I found a way to make use of the patch from 23rd Dec. 20.
    The reproducer is working with the new binaries and the configuration files you provided.
    Unfortunately the output of the sources I'm working on is behaving different.
    I tested the changes with both binary versions (the one from 10th June and the new one of 23.Dec) and the results I get now is, that all sources of my source tree result in xml files called ...filename...c_code.xml contain nothing but the following

    <Content L="1" C="1"></Content>
    

    I think I will try to get the latest Moritz SVN archive next week and will try to make use of the latest patch in combination with the newest LangPack.
    I will give feedback once I managed to run that and how it behaves.
    BR
    Wasili

     
  • Eckard Klotz

    Eckard Klotz - 2021-09-22
    • status: pending --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB