gpt4 book ai didi

c - C中的函数声明器

转载 作者:行者123 更新时间:2023-12-02 06:36:01 26 4
gpt4 key购买 nike

§6.7.6.3 函数声明符

2) The only storage-class specifier that shall occur in a parameter declaration is register.

§6.7.6.3 函数声明符

13) The storage-class specifier in the declaration specifiers for a parameter declaration, if present, is ignored unless the declared parameter is one of the members of the parameter type list for a function definition.

我已经这样声明和定义了......

int function(static int param)
{
return param;
}

Visual Studio 发出警告。我的理解是,如果我们在函数声明中使用 register 作为参数类型,它应该编译时不会出现警告。除了register,它将忽略存储类并向用户抛出警告消息。我的理解正确吗?

谢谢

最佳答案

我相信 6.7.6.3 是说存储类说明符在函数声明中被忽略;它表示除非参数是函数定义的参数类型列表的一部分,否则它会被忽略。由于您显示的是函数定义,因此编译器在此处忽略这个无效的存储类说明符是不合适的。

关于c - C中的函数声明器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18894681/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com