cancel
Showing results for 
Search instead for 
Did you mean: 

Single stepping in a function with an ifdef doesn't match highlighted line of code.

jprinster
Associate II

I have a function with an ifdef in it to conditionally compile a section of code. The ifdef is defined so the code should be active. When I hit a breakpoint before the code the highlighted line of code matches. When I try to single step to the next line of code which is after the ifdef, the highlighted line is outside of the function in a comment block.

I have optimization set to None, but it also doesn't work if it is set for debugging.

I have cleaned and rebuilt but nothing happens. It appears to single step properly in functions that don't have an ifdef.

Thanks, Jim

5 REPLIES 5
AvaTar
Lead

Sounds like the source file displayed is not the one used for the build.

You could do a file system check, and eliminate possible doubles.

I use to put an "# error" directive in the code in such situations. If the compiler does not complain, you have the wrong file.

S.Ma
Principal

Or go step by step in ASM mode to dig to the details. You can then check what is going on or bkpoint as op code level regardless of which source file match what you're debugging.

I tried this and the compiler complained everywhere I put it.

When I looked at the disassembly the code within the ifdef wasn't listed. I went into the folders with the object files and deleted everything and rebuilt but it still didn't show up.

I also had a compile warning on the code within the ifdef, which shows the compiler is seeing it. After cleaning up the warning the code still didn't appear in the disassembly.

Even with the ifdef commented out so the code is inline it still doesn't show up in the disassembly.

Any other suggestions?

Are you sure about the optimization level ?

Virtually all IDEs allow settings on file level.