Dereferencing (int __shuge *) point into (int) variable

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Tools: Keil uVision 4, source code from Tasking IDE, adapted in the way like


#define __shuge huge


Application code:


int __shuge *ptr;
int var;

var = *ptr;


What should I expect with such syntax?
The thing is that there is 0x5151 in memory with say 0x00c40000 address, but I got 0x0000202e instead.

I experimented a bit and found that if

int __shuge *ptr;
int var;

var = *(int)ptr;


then 'var' receives correct value 0x5151.

Why may I have such effect? Is it sufficient way to bypass the bug or it is a lame way?
2 Replies
Juergen
Employee
Employee
hi,

You should use 'long' since shuge(signed huge) is 32 bits, 'int' is 16 bits.

Best Regards
Jurgen
0 Likes
Not applicable
Juergen wrote:
hi,

You should use 'long' since shuge(signed huge) is 32 bits, 'int' is 16 bits.

Best Regards
Jurgen


Well, originally it was long (ulong), the same bug =(
BTW this code is from Infineon EEPROM driver.
0 Likes