Optimization May Prevent Ability to Set Some Breakpoints in CV

ID Number: Q60338

3.00 3.10 3.11 3.14 | 3.00 3.10 3.11 3.12 3.50

MS-DOS | OS/2

Summary:

If you cannot set a breakpoint on a particular line of code with

CodeView, make sure you have compiled with both the /Zi and /Od

compiler options to create executable code that has full CodeView

debugging capabilities.

Due to default or other optimization, some code in the executable is

concatenated if the /Od option is not used to disable all

optimization. The sample code below illustrates this situation.

Compiling the code with Zi but not /Od will prevent you from placing a

breakpoint on the indicated line.

Sample Code

-----------

/* Compile options needed: /Zi

*/

#include <stdio.h>

int func();

void main (void)

{

int a,b,c;

a = func(); /* A breakpoint cannot be set on this line because */

b = a + c; /* optimization concatenates it with this line to */

/* achieve this expression b=(a=func())+c. */

}

int func()

{

return(10);

}

Additional reference words: 3.00 3.10 3.50