开发者

32 bit pointer in a 64 bit Solaris compile

I know this is a strange questions but I was wondering if it was possible to make a 32 bit pointer in 64 bit compile on Solaris using g++. The final object would need to be 64 bit however one of my pointers offsets is becomming larger on Solaris then it is in windows if I do use 64 bit to compile. This is causing a big prob开发者_如何学JAVAlem. I was wondering if it was possible to make a 32bit pointer within my 64 bit compiled object.


Pointer size is a property of your target architecture, so you cannot mix and match 32- and 64-bit pointers. I would strongly suggest re-thinking your design (which smells like usual mistake of casting pointers to integers and back.) You can theoretically work with "limited-reach" offsets, but again please ask yourself why, and what would be a better way of doing it.


You can't change regular pointers, the size of a pointer is sizeof(void *). And if you could, what would you do with an 32bit pointer on an 64bit system?

Do you mean pointers in C or do you maybe mean pointers to a file offset?


If you have pointer type there, then you shouldn't make it 32-bit in 64-bit program. If it is just some offset that not related to memory model, then you could use different type with stable size across platforms, something like uint32_t.


It does not make sense to "need" a 32 bit pointer on a 64 bit machine. I also dont understand this line:

The final object would need to be 64 bit however

I would take a closer look and try to fix the bug on your end. If you post some example code we may be able to help more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜