In C Programming, We can enable/disable loop optimization using #pragma preprocessor directive.
In which scenario, loop optimization should turned off ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Optimisation is off by default when you compile for debug (so that source code lines in the debugger exactly match the code being executed).
You would only use the pragma in very specific circumstances, such as:
You find an optimisation limitation/bug leading to undefined behaviour (What Every C Programmer Should Know About Undefined Behavior (Thanks to @R)
You need exact real-time timing