6849 1512 variable 'xy' might not have been initialized xyz.c

General discussion on mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Slinger251
Posts: 3
Joined: 15 Nov 2022 14:59

6849 1512 variable 'xy' might not have been initialized xyz.c

#1 Post by Slinger251 » 08 May 2023 11:50

Hi, I am trying to get rid of some warning I get from the compiler actually, - having fixed most of them now I cannot fix the last one...
"6849 1512 variable 'xy' might not have been initialized xyz.c"

(First of all - the line of declaration and initialisation looks like this:
unsigned int uiRetval = 0;) the code is running quite well, just don't want to have warnings...

as you see from the fist number the file is quite long > 7000 line, and as it is alle in one function (big switch -case contruct) I think the compiler struggles with it.

I have tried several things like reinit the variable in every "case:", declaration as a global, etc. nothin helped.

As soon as I comment out ~ half of the lines of code - no warning!

any chance to get rid of this warning with all my code active? or to suppress it?


thanks, Marc

Slinger251
Posts: 3
Joined: 15 Nov 2022 14:59

Re: 6849 1512 variable 'xy' might not have been initialized xyz.c

#2 Post by Slinger251 » 09 May 2023 15:19

Hi, ok - I found a solution,

- when declaring the variable as "static" within my function the warnign disappears.
In fact I did not need to store the value of the variable but with now re-initialising the variable on every function call I got no more warnings - fine!

static unsigned int s_uiRetval = 0;
...
s_uiRetval = 0;

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 General”