"sizeof (int)" 中的“(int)”是类型转换运算符还是某些特殊情况参数? [C]

Is the "(int)" in "sizeof (int)" a typecast operator or some special case parameter? [C]

我一直假设 C 表达式 sizeof (int) 像函数一样工作,括号内的任何内容都像参数一样传递。由于 int (或任何其他类型说明符)实际上是一个关键字而不是可以传递的对象,我认为它只是某种硬编码到编译器中的特殊情况。

但我最近发现,如果我在变量上使用 sizeof,我可以省略括号 (sizeof var),它会编译并且 运行 很好。由于 sizeof 实际上是一个运算符本身而不是一个函数(并且运算符不需要括号),并且类型说明符是唯一需要括号的东西,现在我想知道它们是否真的是类型说明符或者是否它们实际上是 sizeof 以某种方式使用类型转换运算符来查找相应类型的大小。

如果操作数是 数据类型 .

,则

()sizeof 运算符一起使用

C11: 6.5.3.4 (p2):

The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand.