Hi,
I'm using code warrior IDE version 5.9.0 for MPC55xx/56xx.
According to my preference setting, the global variables should be purple.
I declared the struct variable such as ,
// aaa.h
struct _A
{
uint8_t a:1;
uint8_t b:1;
uint8_t :6;
}
void floor(void);
#ifdef _aaa_h_
struct _A a_struct;
#else
extern struct _A a_struct;
#endif
// aaa.c
#include "aaa.h"
void floor(void)
{
a_struct.a = 1;
}
I think that the struct variable 'a_struct' will be purple. But it doesn't. Its color is white (foreground).
There is no compile error.
When I declare the struct variable in main.h and main.c, It works,
But in other source, header files, It doesn't apply.
Is It just a bug?
Somewhat probably unrelated, but:
You have this:
#ifdef _aaa_h_
struct _A a_struct;
#else
extern struct _A a_struct;
#endif
which is very unusual and even very dangerous: you never should have variable definitions in header files except you know exactly what you are doing. Because depending on that define and potentially include orders you will have multiple definitions. What you really should have is
extern struct _A a_struct;
in aaa.h
and
struct _A a_struct;
in aaa.c.
As a positive side effect, I guess your coloring thing will go away too.
I hope this helps,
Erich
You are right, Thank you :smileyhappy:
Regards,
Jaehak Kim