C preprocessors in GCC-AVR & AVR studio

Aug 22, 2004 3 Replies

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?


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! visi.com

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() { :

}

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.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required