Hacker News new | ask | show | jobs
by foxhill 4703 days ago
i used to think like you do, but this changed my mind;

    int *a;
        
is saying, when you dereference a, you have an integer.

and when you think about it - a pointer is the same length for any data type, even pointers to functions, so it would be pointless to have a different pointer type for each data structure.

1 comments

> a pointer is the same length for any data type, even pointers to functions

No that's not guaranteed despite being common. And function pointers are not even guaranteed to be representable by void* (POSIX08 does mandate it though.)

Relevant sections of the standard here http://stackoverflow.com/a/3941867/1546653