[NSWI004] simple_printf with pointers

Petr Tůma petr.tuma at d3s.mff.cuni.cz
Thu Oct 8 21:09:48 CEST 2020


Hi Krisztian,

what data loss exactly do you observe and what platform does that happen on ? The C language standard defines uintptr_t, an integer large enough to store a pointer (https://stackoverflow.com/questions/1845482/what-is-uintptr-t-data-type), so it is safest to use that - however, if you use a typical machine then both void * and unsigned long int would be 8 bytes and your problem is probably somewhere else.

Petr


On 08/10/2020 21:03, Krisztian Bokor wrote:
> Good evening,
> 
> I'm having trouble with printing pointer addresses in my simple_printf function: if I cast the void* pointer to unsigned long int, that causes a bit of data loss, and the value changes slightly. What other approach should I use?
> 
> Thank you in advance,
> Krisztián Bokor
> 
> _______________________________________________
> NSWI004 mailing list
> NSWI004 at d3s.mff.cuni.cz
> https://d3s.mff.cuni.cz/mailman/listinfo/nswi004
> 


More information about the NSWI004 mailing list