“类型和尺寸说明符” - 术语
请看以下片段:
1 #include <stdio.h>
2 #include <stdlib.h>
3 int foo(char [6]);
4
5 int main(void) {
6 char* bar="hello";
7 return foo(bar);
8 }
9
10 int foo(char f[6]) {
11 return EXIT_SUCCESS;
12 }
13
第 3 行“char [6]”的正确技术术语是什么?我将其称为“类型和大小说明符”,它仅描述编译器的用途。
整个第 3 行我用来调用“函数的调用堆栈签名”或简称为“函数签名”。与“函数实现”相反,“函数声明”或“函数原型”也是正确的。
注意:您不需要向我解释有关调用堆栈、框架、调用约定等的所有内容。等人。我只是在那里寻找正确的术语。不是整个第 3 行,只是如何调用一个说明符,例如“char [6]”。
Take the following snippet:
1 #include <stdio.h>
2 #include <stdlib.h>
3 int foo(char [6]);
4
5 int main(void) {
6 char* bar="hello";
7 return foo(bar);
8 }
9
10 int foo(char f[6]) {
11 return EXIT_SUCCESS;
12 }
13
What is the right technical term for "char [6]" on line 3? I call it "type and size specifier" which merely describes what its used for by the compiler.
The entire line 3 I use to call "call stack signature of the function" or simply "function signature". "function declaration" or "function prototype" would also be correct, as opposed to "function implementation".
Note: You don't need to explain me everything about call stacks, frames, calling conventions et. al. I'm only looking for the right terminology there. NOT the entire line 3, only how to call one single specifier, like "char [6]".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 C 标准 (ISO 9899:1999) 中,这是一个参数类型说明符,如果该说明符中没有标识符,则该参数被称为未命名。
任何“大小”概念都是类型的一部分(大小未知的数组类型被称为不完整)。请注意,这里的
[6]
构造不定义数组类型,而是定义指针类型(参数列表中的顶级数组声明符会自动转换为指针声明符,并且假定的数组大小将被忽略) 。In the C standard (ISO 9899:1999), this is a parameter type specifier and, if there is no identifier in that specifier, the parameter is said to be unnamed.
Any notion of "size" is part of the type (an array type with unknown size is said to be incomplete). Note that here, the
[6]
construction does not define an array type but a pointer type (top-level array declarators within parameter lists are automatically converted to pointer declarators, and the putative array size is ignored).在 C 语法中,第 3 行的
char [6]
是一个parameter-type-list
,由单个parameter-list
组成,它由一个参数声明
组成。该
参数声明
由声明说明符
(char
)和抽象声明符
( <代码>[6])。In the C grammar, the
char [6]
on line 3 is aparameter-type-list
, consisting of a singleparameter-list
, which consists of a singleparameter-declaration
.That
parameter-declaration
is made up of adeclaration-specifier
(char
), and anabstract-declarator
([6]
).