Menu

#18 #if ( ... ) fails

Moritz_2_0_1
closed
None
3
2021-01-01
2020-12-28
No

Hello Eckard,

I have code like this which breaks te parser

int test(void){
#if ( TEST == 1 )
  return 1;
#elif  ( TEST == 2 )
  return 2;
#else
#error unexpected 
#endif
}

I'm not sure if this is C99 conform but the ARM compiler is handling it.
BR
Wasili

Discussion

  • Wasilios Goutas

    Wasilios Goutas - 2020-12-28

    reproduser attached

     
  • Eckard Klotz

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

    Eckard Klotz - 2020-12-28

    Hello Wasili.

    I have tested your examples with the newest Moritz patch published on 2020-12-23 together with the patch I have provided to solve your issue struct initializer with condition

    • But I was not able to reproduce your issue.
    • I don't want to add the complete XML output here but as far as I can see every path of your compiler-switch is present including the error-directive.

    The Nassi Shneiderman diagram for it looks like this:


    test ( )


    int test ( )
    PREPROSESSOR ALTERNATIVES PREPROSESSOR DEFAULTS
    #if ( TEST == 1 )
    return 1
    #elif ( TEST == 2 )
    return 2
    #else
    #error unexpected

    (Note: Here in the Forum the HTML result looks a little bit different. But you see that all your code-parts are present )

    I wish you a happy new year.

    Stay healthy,
    Eckard.

     

    Last edit: Eckard Klotz 2020-12-28
  • Eckard Klotz

    Eckard Klotz - 2021-01-01
    • status: pending --> closed
     

Log in to post a comment.