OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 1:49 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How do I change the size of void*?
PostPosted: Tue Jun 02, 2020 3:54 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 293
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?


Top
 Profile  
 
 Post subject: Re: How do I change the size of void*?
PostPosted: Tue Jun 02, 2020 4:03 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
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.


Top
 Profile  
 
 Post subject: Re: How do I change the size of void*?
PostPosted: Tue Jun 02, 2020 4:20 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 293
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.


Oops, I expected that its size depends on the compiler.
Thank you, I will refuse to calculate addresses in uint64_t.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 68 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group