Kyle_109
Kyle_109

Reputation: 41

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 problem. I was wondering if it was possible to make a 32bit pointer within my 64 bit compiled object.

Upvotes: 1

Views: 407

Answers (4)

Ed Swangren
Ed Swangren

Reputation: 124642

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.

Upvotes: 0

Kirill V. Lyadvinsky
Kirill V. Lyadvinsky

Reputation: 99585

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.

Upvotes: 0

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84169

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.

Upvotes: 1

Johannes Weiss
Johannes Weiss

Reputation: 54031

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?

Upvotes: 0

Related Questions