编译器错误 C3540

“type”: sizeof 不能应用于包含“auto”的类型

sizeof 运算符不能应用于指定的类型,因为它包含 auto 说明符。

示例

下面的示例会产生 C3540。

// C3540.cpp
// Compile with /Zc:auto
int main() {
    auto x = 123;
    sizeof(x);    // OK
    sizeof(auto); // C3540
    return 0;
}

请参见

参考

auto 关键字

/Zc:auto(推导变量类型)

sizeof 运算符