Author Topic: C language: CAN NOT parse anonymous struct which is located in one union;  (Read 1630 times)

Tiger

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
struct anonymous_t
{
    int b1                           :  1;
    int b2                           :  1;
    int b3                           :  1;
    int b4                           :  1;
    int b5                           :  4;
    int resv                                  : 24;
};
typedef union ctrl_u
{    int u32;
    struct anonymous_t; /* anonymous struct */
} T_CTRL;

int main ()
{
    T_CTRL reg;

     reg.b6 = 0; /* cant complete reg.b6 */

    return 0;
}

there is an old topic files many years ago,
https://community.slickedit.com/index.php/topic,1973.msg8272.html#msg8272
but this issue still not fixed in my version SlickEdit Pro 2018 (v23.0.0.10 64-bit)

there are lots of header file is created automatically by digital design tool;
this union is used to access register bit;
it's very convenient to use reg.b1 instread of reg.xxx.b1;
most important , this anonymous struct is supported by stand C:
why slickedit not support?




Dennis

  • Senior Community Member
  • Posts: 3960
  • Hero Points: 517
Re: C language: CAN NOT parse anonymous struct which is located in one union;
« Reply #1 on: September 28, 2020, 02:20:51 PM »
I was not aware that was even allowed.  I will look into it and see if a simple fix can be done for v25.

Dennis

  • Senior Community Member
  • Posts: 3960
  • Hero Points: 517
Re: C language: CAN NOT parse anonymous struct which is located in one union;
« Reply #2 on: September 28, 2020, 05:42:28 PM »
This will be handled in SlickEdit 2020 (version 25).

Note, those cases in that older set of posts probably did not work correctly because of the "__no_init" extension being used.  You can work around that by defining it in your C/C++ Preprocessing options.

Tiger

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: C language: CAN NOT parse anonymous struct which is located in one union;
« Reply #3 on: September 29, 2020, 01:52:59 AM »
int main ()
{
    T_CTRL reg;

     reg.b1 = 0; /* cant complete reg.b1 */

    return 0;
}
sorry, it should be "reg.b1" , NOT "reg.b6"

Tiger

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: C language: CAN NOT parse anonymous struct which is located in one union;
« Reply #4 on: September 29, 2020, 02:34:04 AM »
in vscode it can be parsed;
see attached image;