typedef struct
{
int a;
int b;
int c = a+b;
} my_struct_t;
int res;
my_struct_t A = '{2,3,res};
May I know if res would be 5 ?
typedef struct
{
int a;
int b;
int c = a+b;
} my_struct_t;
int res;
my_struct_t A = '{2,3,res};
May I know if res would be 5 ?
In reply to zz8318:
No. Your initialization of my_struct replaces the default initialization of my_struct_t.
And even if that were not the case, SystemVerilog does not define ordering between initializations,
In reply to zz8318:
As a follow-up to Dave’s comment, your code is illegal and won’t compile. Section 7.2.2 of the LRM requires assigned expressions to be constant, where ‘int c = a+b’ doesn’t meet this requirement.
Thanks both !