C
Chris Hauxwell
I think the following code should give an error when compiled,
however, the compiler I am using doesn't raise one. The code is:
typedef struct
{
char a1;
char a2;
char a3;
} A_T;
typedef struct
{
char b1;
const A_T ba;
} B_T;
B_T b;
void main(void)
{
b.ba.a1 = 0;
}
Should this give an error? I've declared the A_T part of B_T as a
const and then written to it in main(). I think it should, but my
compiler is happy with it. Any comments will be appreciated.
Thanks
Chris
however, the compiler I am using doesn't raise one. The code is:
typedef struct
{
char a1;
char a2;
char a3;
} A_T;
typedef struct
{
char b1;
const A_T ba;
} B_T;
B_T b;
void main(void)
{
b.ba.a1 = 0;
}
Should this give an error? I've declared the A_T part of B_T as a
const and then written to it in main(). I think it should, but my
compiler is happy with it. Any comments will be appreciated.
Thanks
Chris