Skip to main content
jprinster
Associate II
February 12, 2019
Question

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

  • February 12, 2019
  • 2 replies
  • 1414 views

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

This topic has been closed for replies.

2 replies

AvaTar
Senior III
February 13, 2019

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.

jprinster
jprinsterAuthor
Associate II
February 13, 2019

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

AvaTar
Senior III
February 14, 2019

Are you sure about the optimization level ?

Virtually all IDEs allow settings on file level.

S.Ma
Principal
February 13, 2019

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.

jprinster
jprinsterAuthor
Associate II
February 13, 2019

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?