Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

define 32bit on 64bit

i have some C files here (you don’t need to know what’s inside), it’s in stable 32bit mode (with gcc -m32), now i want to do more 64bit (gcc -m64) it has some minor bugs\

  • question:
    so how to use a 32bit C number (how 32bit works), on 64bit\
  • more understandable explanation:
    i want to use 32bit in 64bit mode (-m64, there is some way works 32bit C cannot work in 64bit C)
    The most common error about this problem:
    "Cast to pointer from integer of different size"

    I really need help!\

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"Cast to pointer from integer of different size"

Oh no. Go through your code and get rid of all casts between pointer and integer that don’t convert from or to intptr_t, uintptr_t, or ptrdiff_t. If you convert between pointer and other-sized integer it won’t work no matter how many layers of indirection you use.

Once you’ve done that and you still need certain-sized integers for I/O reasons use the definitions from stdint.h:

int16_t: signed 16 bit integer

uint16_t: unsigned 16 bit integer

int32_t: signed 32 bit integer

uint32_t: unsigned 32 bit integer

int64_t: signed 64 bit integer

uint64_t: unsigned 64 bit integer

Keep size_t for array sizes, don’t use it in on-disk formats. It changes.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading