Hello, dear friends:
I am a user of mikroC PRO for PIC in China, I have a question about the compiler. In the output setting, there is a option for Optimization level,the scope is from Zero to Five. What level is the best choice? Because I find that sometimes I program the MCU, the code in my device is not normal, but after I change the Optimization level(from four to zero), maybe the code in my device is normal. But when I modify my code and then program, the code in my device is not normal again, I have to change the Optimization level again, maybe
the code is normal. I am very sure the code is correct in logic. I doubt that maybe the Optimization cause some problems, and maybe the complier option is not correct in my mikroC ,so I have to send a mail to you, Can anyone help me something? Thank you
question about the mikroC
Re: question about the mikroC
Besides the optimization level 0 (which does not mean no-optimization), there is usually no noticeable difference in optimizer performance. It's best to use the default optimization level (4), as for this level one may be pretty sure that mE did perform compiler tests. Same about users' feedback in finding compiler quirks and errors.
As for differing code behaviour after program changes, it's most frequently a sign of variable overwriting due to faulty variables declaration or code. Even small code change may produce completely different variables distribution in RAM and thus a problem may show up or disappear. It's possible that switching between 0 and other optimization levels may, for specific code, lead to similar effects.
As for differing code behaviour after program changes, it's most frequently a sign of variable overwriting due to faulty variables declaration or code. Even small code change may produce completely different variables distribution in RAM and thus a problem may show up or disappear. It's possible that switching between 0 and other optimization levels may, for specific code, lead to similar effects.
Re: question about the mikroC
Hello, you said that due to faulty variables declaration or code, but the code is compiled successfully,how do I check the code?thanksjanni wrote:Besides the optimization level 0 (which does not mean no-optimization), there is usually no noticeable difference in optimizer performance. It's best to use the default optimization level (4), as for this level one may be pretty sure that mE did perform compiler tests. Same about users' feedback in finding compiler quirks and errors.
As for differing code behaviour after program changes, it's most frequently a sign of variable overwriting due to faulty variables declaration or code. Even small code change may produce completely different variables distribution in RAM and thus a problem may show up or disappear. It's possible that switching between 0 and other optimization levels may, for specific code, lead to similar effects.
Re: question about the mikroC
Compiler doesn't check index range in array access, for example, so code may compile but it still may overwrite variables following an array in RAM. There are many ways to produce faulty code that compiles .
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: question about the mikroC
Hi,
If you are switching Optimization level this can cause some changes in your code.
Since optimization will make some changes in your project due to the code size and save space in your memory for example.
Regards,
Aleksandar
If you are switching Optimization level this can cause some changes in your code.
Since optimization will make some changes in your project due to the code size and save space in your memory for example.
Regards,
Aleksandar
Re: question about the mikroC
There are (infinite) much more possibilities that the code is faulty than possibilities that it is correct. Additionally one can never prove the code is correct, only that it is "faulty" or in "no fault popped up yet" state.janni wrote:There are many ways to produce faulty code that compiles .
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
-
- Posts: 43
- Joined: 30 Nov 2012 22:01
Re: question about the mikroC
The optimization level 0 I've got with mikroC 6.0.0 can't even optimize trivial stuff like x*2, x % 2, x / 2janni wrote:Besides the optimization level 0 (which does not mean no-optimization)
I think it means 0 optimization...