Hi
my LCD display is working, but now I have a strange issue with variables and functions.
if you look a the attached KEIL listing (which I originally started to see why mybuf is not filled with the
content of myinput),
you see that line 187 and 191 are not at all seen and executed (the dark grey bar equals "executed").
halInit(), and chSysInit() are.
I have no idea why.
line 187 is jumped when doing single step and so is 191.
When I had the code for myfunc directly embedded in "main()", the mybuf = myinput would not execute.
I tested my full code with Visual C, where it works fine.
Also, BTW, if I do not declare "o" as static, the whole " int o...o++" will not be executed. (That still does not explain the myfunc issue but might be connected).
Thanks for all help.
Merry Christmas!
C issue or Keil issue (or my issue)
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: C issue or Keil issue (or my issue)
Optimizations, the skipped code does nothing or is optimized out.
Giovanni
Giovanni
Re: C issue or Keil issue (or my issue)
Giovanni wrote:Optimizations, the skipped code does nothing or is optimized out.
Correct. The compiler does see that the variable is not used anywhere and therefore it's useless. You can change optimization levels in your Makefile. It's the -O flag. Simply change from -O3 to -O0
~ Tectu
Re: C issue or Keil issue (or my issue)
Hi guys,
merry Christmas..
I am amazed! So the compiler knows that a function is not effecting anything (since it's only a test and has no return value).
And the two times o++ will be combined....
You saved my sanity!
I guess at will not turn on optimization as long as the code is tested...
Thanks
merry Christmas..
I am amazed! So the compiler knows that a function is not effecting anything (since it's only a test and has no return value).
And the two times o++ will be combined....
You saved my sanity!
I guess at will not turn on optimization as long as the code is tested...
Thanks
Re: C issue or Keil issue (or my issue)
I was happy to early.
Unfortunately when setting optimization to "0" some other stuff does not work
like halInit(); in the example about never returns.
Unfortunately when setting optimization to "0" some other stuff does not work
like halInit(); in the example about never returns.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: C issue or Keil issue (or my issue)
Hi and Merry Christmas,
This can be caused by stack overflows or other similar problems, the stack usage increases when optimizations are disabled. You need to step into the code and see where it fails and how it fails. "Does not work" is too generic.
Giovanni
This can be caused by stack overflows or other similar problems, the stack usage increases when optimizations are disabled. You need to step into the code and see where it fails and how it fails. "Does not work" is too generic.
Giovanni