I'm using a gcc cross-compiler, I'm writing a memory Manager that uses uint64_t to compute addresses, and then converts it to void*(kmalloc does this) for further use.
I get this error "error: cast to pointer from integer of different size".
As I understand the size of void* is 32 bits, how do I change it to 64 bits?
How do I change the size of void*?
Re: How do I change the size of void*?
Size of void* depends on the architecture (and/or mode of operation) you are compiling for. It's 4 bytes for x86, 8 bytes for x86-64, etc. It's just a generic pointer. You probably have some problems with compiler flags, which causes it to compile for wrong architecture. Or you messed up something in paltform description files. BTW. you are not supposed to use strictly sized types for address calculcations. There is uintptr_t type used specifically for that purpose. It is supposed to always be the same size as void*. Also, that error you are getting is actually a warning (I think) which has been promoted to error by the use of -Werror compile flag.
Re: How do I change the size of void*?
Oops, I expected that its size depends on the compiler.pvc wrote:Size of void* depends on the architecture (and/or mode of operation) you are compiling for. It's 4 bytes for x86, 8 bytes for x86-64, etc. It's just a generic pointer. You probably have some problems with compiler flags, which causes it to compile for wrong architecture. Or you messed up something in paltform description files. BTW. you are not supposed to use strictly sized types for address calculcations. There is uintptr_t type used specifically for that purpose. It is supposed to always be the same size as void*. Also, that error you are getting is actually a warning (I think) which has been promoted to error by the use of -Werror compile flag.
Thank you, I will refuse to calculate addresses in uint64_t.