isn't actually initialized as a pointer I changed all my C code to marking * before the variable name, fun times. It's helpful to think int as the base type and * the indicator of functionality like [] and ().
Also just found out the author was the developer of Adium [1], which is one of my favorite softwares (best logo) on macOS.
I used to use that years ago! I had to stop when everyone moved over to Facebook Chat (what became Messenger) and eventually made a breaking change Adium couldn't support.
By C half-assedly trying to make "* " part of the name, just so you can use "* ptr" everywhere like it is an actual variable name, you get confusions such as this.
First "foo_ptr's type is int * ", but then "The pointer has a type, too, by the way. Its type is int.".
I also refuse to agree with "An int * * 's type is int * ". :)
But I guess "the type of `* ptr` is int, the type of `ptr` is int * " would be even more confusing.
> Pointers in C are a much higher level abstraction.
Not really; almost all programmers treat them as addresses and almost all compilers represent them that way. Regardless of what the standard actually says. Leading to surprises when this doesn't hold true, and awkwardnesses of the 16-bit x86 "near/far" pointers.
I mean, that's the only reason that "array[index]" and "index[array]" are interchangeable; you don't see that in other languages.
The article talks about the size of the pointee in memory though, not the size of the pointer.
An 'int' is usually 4 bytes wide when compiling for 64-bit ISAs (at least I haven't seen situations yet where this isn't the case, my experience is limited to x86 and ARM though). Modern C fixes this ambiguity with sized integer types (e.g. int32_t vs int64_t).
>The article talks about the size of the pointee in memory though, not the size of the pointer.
Yes, you're right about the article's text. When I read gp ChrisSD's comment in isolation where he quotes ">A pointer is a memory address" -- followed immediately by him quoting ">On current mainstream Intel processors, _it_ occupies four bytes of memory"
... I thought the "_it_" was referring to a "pointer" instead of plain "int". It didn't occur to me to that the actual article has extra text in between those 2 extracted quotes which drastically changes the assumption of what the pronoun "it" means. My mistake.
Also just found out the author was the developer of Adium [1], which is one of my favorite softwares (best logo) on macOS.
[0] http://c-faq.com/decl/charstarws.html
[1] https://adium.im/
isn't actually initialized as a pointer I changed all my C code to marking * before the variable name, fun times. It's helpful to think int as the base type and * the indicator of functionality like [] and ().