C preprocessors in GCC-AVR & AVR studio

Hi,

I am using GCC and AVR sudio in my MCU project. I find a big problem when the two tools are used together.

My C program has many "#ifdef"/"#endif" instruction segments to control different compilation options. However, when I debug the program in AVR studio and set watch points, some locations are misaligned so that the real position of instruction lines cannot be really located. I knew that becaue I found that some instruction lines cannot be set watchpoint successfully. So this brings a lot of troubles to me.

Could anyone teach me how to solve the problem? Or I need to remove those preprocesors?

Reply to
terry
Loading thread data ...

I'd be very, very surprised if the preprocessor stuff is causing problems.

Most likey, you need to turn off optimization in the compiler. With optimization enabled, lines get eliminated and re-arranged.

--
Grant Edwards                   grante             Yow!  Half a mind is a
                                  at               terrible thing to waste!
 Click to see the full signature
Reply to
Grant Edwards

I think the problem i not in the optimization. For example, if A is not defined in the following, the alignment would become wrong in b() funciton. Setting or not setting optimization cannot help. : : #ifdef A void a() { : : } #endif : : void b() { :

}
Reply to
terry

This might be an oversimplification of your problem, but you know that changing the source code after the last compilation can cause alignment problems for most source-level debuggers.

Reply to
George

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.