C: Difference between revisions

584 bytes added ,  14 years ago
→‎Things you should know about optimizations: Added opposite opinion discussed at http://forum.osdev.org/viewtopic.php?f=1&t=20697
[unchecked revision][unchecked revision]
m (Killing "PlusPlus")
(→‎Things you should know about optimizations: Added opposite opinion discussed at http://forum.osdev.org/viewtopic.php?f=1&t=20697)
Line 31:
 
To fix possible issues due to optimizations performed by processors on runtime (e.g. reordering instructions and memory accesses, caching memory) make sure you use [[atomic operation]]s or [[memory barriers]] where neccessary. This however isn't an optimization specific to the C/C++ language but rather platform and hardware specific.
 
However, although optimizations increase the severity and apparent number of small bugs in C code, they will never break correct C, assuming the compiler is stable and multi-threading issues are accounted for. Because of this, it is sometimes best to debug with optimizations enabled at all different levels, to make sure that code is absolutely correct. If optimizations are turned off, the bugs are still there, just less noticeable. A release-quality project should work while enabling any combination of optimizations, although it is much harder to make progress while doing so.
 
== Learning C ==
Anonymous user