Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Typedef'ng a variable

Status
Not open for further replies.

TucsonDon

Member
Other than the obvious (declaring a data type), what is the difference in typedef of a variable, for example if I declare a structure or I typedef a structure. Does the complier place in program memory or data memory?

I have a program that I am trying to debug but I am unable to see the values in a declared structure elements (MPLab).
 
The typedef is just a shortcut version or macro of the full data type or structure etc., it should not make any difference to the compiled program.

The variables should be in RAM, unless it's an array or structure loaded with pre-defined "const" data as it is defined; that could be in program memory or auto-copied to data memory.

To see variable while single stepping, you may have to make them global rather than local. I've had problems when trying to debug using local variables used.
 
Depending on the compiler type... I use XC8 pro.. When debugging I have to dissable ANY!! optimizations.. If the linker see's a variable is declared and initialized but not used.. It omits it so it isn't there..

If you are using variables that are used in two or more functions they must be declared volatile or the same thing happens... Locals though... Well if they are missing when debugging, can be viewed on the stack..

these are in order from the calling function's address..
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top