So le'ts try to explain myself as simple as possible ! let's say that I have one function with the following prototype :
And that can return a pointer to either a u8, u16, u32 (depeding of the case, and this is not the case in which the returned value type is not the exptected one), Then this fct is called by an other one like :void* get_something(_u32 parameter);
In the above case the expected return value is a u16, so it should work, but calling it result in garbages in *ptr, and only a bad hack like the following one allow to get the correct return value...._u16 myFct(_u32 parameter)
{
_u16* ptr = get_something(parameter);
if (ptr == NULL)
return 0;
else
return *ptr;
}
Casting have no effect, and compiler keep complains on "casting pointers from different sizes" if I cast it.
So just declaring it as a u8..._u16 myFct(_u32 parameter)
{
_u8* ptr = get_something(parameter);
if (ptr == NULL)
return 0;
else
return ptr[1]<<8|ptr[0];
}
I have similar fct that are waiting for a u8 and u32...
only _u8 is working fine, as it "seems" to be the only possible things returned, but for _u32 value, the only way to make it working is to apply the same kind of stuff that above...
What is the problem ?? This code is working just fine when compiled and ran on a PC..
Is it me, or is there any issue with pointer in the GCC, SDK ??
thanks..