- 论坛徽章:
- 0
|
-------------------英文版----------------
The Precedence Rule for Understanding C Declarations
Step A : Declarations are read by starting with the name and then reading in precedence order.
Step B : The precedence, from high to low, is:
Step B.1 : parentheses grouping together parts of a declaration
Step B.2 : the postfix operators: parentheses () indicating a function, and square brackets [] indicating an array.
Step B.3 : the prefix operator: the asterisk denoting "pointer to".
Step C : If a const and/or volatile keyword is next to a type specifier (e.g. int, long, etc.) it
applies to the type specifier. Otherwise the const and/or volatile keyword applies to the
pointer asterisk on its immediate left.
------------------中文版-------------------
理解C语言声明的优先级规则
A 声明从它的名字开始读取,然后按照优先级顺序依次读取:
B 优先级从高到低依次是:
B.1 声明中被括号括起来的那部分
B.2 后缀操作符:
括号()表示这是一个函数、而
方括号[]表示这是一个数组。
B.3 前缀操作符:星号*表示“指向…的指针”。
C 如果const和(或)volatile关键字的后面紧跟类型说明符(如int,long等),那么它作用于类型说明符。在其 他情况下,const和(或)volatile关键字作用于它左边紧邻的指针星号。
[ 本帖最后由 duke_gun 于 2006-1-10 10:28 编辑 ] |
|