#include <stdio.h>
int main()
{
printf("%d", sizeof(struct token *));
}
The above code can be compiled and linked use gcc under Linux. Could anyone of you explain the thing behind the Scenes to me? I know the point take the fix size of memory, so the struct
token is irrelevant to sizeof, but even turn on the warning option in gcc, no warnings about the “none exist” struct at all. The context for the question is that I’m reading some source code by others, I’m trying very very hard to find the definition of “struct token”, but off course failed.
Because you are trying to get the size of a pointer to
struct token. The size of a pointer doesn’t depend on how the structure is actually defined.Generally, you can even declare a variable of type
struct token*, but you can’t dereference it (e. g. access a member through the pointer).