开发者

"Type and Size Specifier" - Terminology

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]".


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).


In the C grammar, the char [6] on line 3 is a parameter-type-list, consisting of a single parameter-list, which consists of a single parameter-declaration.

That parameter-declaration is made up of a declaration-specifier (char), and an abstract-declarator ([6]).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜