是否有场景中可以有差异之间sizeof(struct structure_name)和sizeof(object)其中object的类型是struct structure_name用C?
没有有什么区别sizeof(type),并sizeof(o)在声明的类型o是type.
如果对象的声明类型不能真正代表对象,则可能存在差异.例如
char arrayValue[100];
sizeof(arrayValue); // 100 on most systems
char* pointerValue = arrayValue;
sizeof(pointerValue); // 4 on most 32 bit systems
Run Code Online (Sandbox Code Playgroud)
之所以出现这种差异,是因为它sizeof是C语言中的编译时构造.因此,没有运行时分析,编译器会查看静态声明的类型.