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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. A pointer may be larger or smaller than an integer in size. If you need to pass a pointer as an integer for some reason (like performing integer, rather than pointer, arithmetic), they are guaranteed to fit into an intptr_t.
They are not guaranteed to fit into a size_t as suggested in another answer, but in practice it is unlikely that they won’t, since the largest addressable size is usually equal to the largest addressable address.