Is it safe to assume that a pointer is the size of an int in C?

前端 未结 7 917
别那么骄傲
别那么骄傲 2020-12-20 16:52

In designing a new programming language, is it safe to assume that a C int and a pointer are the same size on the machine?

7条回答
  •  一整个雨季
    2020-12-20 17:29

    No; on my MacOS X 10.6.5. machine, an int is 32 bits and a pointer is 64 bits by default.

    If you need an integer that's the right size to hold a pointer too, use #include (or ) and uintptr_t - assuming you have C99 support, or can simulate it.

提交回复
热议问题