-5

Why ANSI has kept the size of pointer variable 2 byte in C (16 bit).

JBentley
  • 6,099
  • 5
  • 37
  • 72
dubex
  • 1
  • sorry, i have specified for 16 bit machine – dubex Jun 04 '14 at 17:14
  • 4
    It hasn't. It never defined the size of pointers in the first place. An *implementation* chooses a pointer size, and that makes perfect sense. What's the point of 64 bit pointers when you only have 65K of memory? –  Jun 04 '14 at 17:14
  • The size of a pointer variable depends on the compiler and the target system. – harper Jun 04 '14 at 17:14
  • the size of pointers is implementation defined – bolov Jun 04 '14 at 17:14
  • They don't determine the size of pointers (or just about anything) on any implementation, the implementation creators do. – Maple Jun 04 '14 at 17:16
  • C++ and C are not the same language. I've removed the C++ tag as the question is about C. – JBentley Jun 04 '14 at 17:17
  • @JBentley "C++ and C are not the same language", then why mark this C post as a duplicate of a C++ post? – chux - Reinstate Monica Jun 04 '14 at 17:32
  • @Chux I did not (IIRC my vote was for "unclear" since the question starts from a flawed premise and is therefore unanswerable). Unfortunately when people give multiple reasons for a close-vote, it displays the reason which got the most votes. I've flagged it. – JBentley Jun 04 '14 at 17:41

2 Answers2

2

ANSI hasn't and never will, to find out what your implementation does use:

sizeof(void *)
Paul Evans
  • 27,315
  • 3
  • 37
  • 54
1

The size of a void* pointer is the address size of the CPU, as it has to be able to hold any possible memory address. For a 64-bit system, it has to be (at least) 64 bits.

mrks
  • 8,033
  • 1
  • 33
  • 62
  • "size of a void* pointer is the address size of the CPU" may be true in general, but not always so. Example: pre 286 Intel processors had segmented architectures, independently used 16 or 32 bit pointers for code, data and the address size was 20-bit. – chux - Reinstate Monica Jun 04 '14 at 17:26