The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
I have some code that I want to run on a microcontroller. One piece of the code basically says:
var = 0;
var = 1;
var = 0;
but it is important that these instructions get executed, because var maps to a signal getting sent to the real world, and var needs to stay high for a clock cycle and then go low again.
I'm scared that gcc will optimize this out when it comes time to compile the final version. Is there a keyword to prevent my statements from being touched?
If you're using the compiler only for the micro recompile it without the optimizations. The switch should be listed in ./configure --help
Not sure how to do it just for a file.
Posts
volatile int var;
Not sure how to do it just for a file.
might also do the trick. lower number = less optimizing, might be just a CPU thing tho.
I've never tested this but K&R says it should work.
This is the way to go.
-O0 (no optimizations) is the default, there's no need to set an option for it.