Dear All,
I am using CodeWarrior v.5.9.0 (build 2404) with an MC9S08QE64 MCU and in my project I get the warning:
C5651: Local variable <variable> may be not initialized
This is the piece of code written to stimulate the warning:
typedef struct{
char par1 :4;
char par2 :4;
}typeparam;
char fun(typeparam param);
void main(void) {
typeparam data;
char ret;
EnableInterrupts;
data.par1 = 2;
data.par2 = 1;
ret = fun(data);
for(;; ) {
__RESET_WATCHDOG();
}
}
char fun(typeparam param){
if(param.par1 == 1) return 1;
if(param.par2 == 2) return 2;
return 3;
}
The variable data in main function seems to be initialized but I get the warning:
C5651: Local variable "data" may be not initialized
Could someone explain me why?
Thanks,
Mirko.
Solved! Go to Solution.
typedef unsigned char typeparam; enum /* bit masks */ { par1 = 0xF0, par2 = 0x0F, }; enum /* bit values */ { par1_1 = 0x10, par1_2 = 0x20, par2_1 = 0x01, par2_2 = 0x02, }; ... void main() { typeparam data; char ret; data = par1_2 | par2_1; ret = fun(data); ... } char fun(typeparam param) { if((param & par1) == par1_1) { return 1; } ... }
Thank you very much.
Mirko.
typedef unsigned char typeparam; enum /* bit masks */ { par1 = 0xF0, par2 = 0x0F, }; enum /* bit values */ { par1_1 = 0x10, par1_2 = 0x20, par2_1 = 0x01, par2_2 = 0x02, }; ... void main() { typeparam data; char ret; data = par1_2 | par2_1; ret = fun(data); ... } char fun(typeparam param) { if((param & par1) == par1_1) { return 1; } ... }