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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…