声明摘要

declaration
declaration-specifiers attribute-seqopt1 init-declarator-listopt ;
static_assert-declaration

declaration-specifiers
storage-class-specifier declaration-specifiersopt
type-specifier declaration-specifiersopt
type-qualifier declaration-specifiersopt
function-specifier declaration-specifiersopt
alignment-specifier declaration-specifiersopt

attribute-seq1
attribute1 attribute-seqopt1

attribute1、2:以下项之一
__asm __based __cdecl __clrcall __fastcall __inline __stdcall __thiscall __vectorcall

init-declarator-list
init-declarator
init-declarator-list , init-declarator

init-declarator
declarator
declarator = initializer

storage-class-specifier
auto
extern
register
static
_Thread_local
typedef
__declspec ( extended-decl-modifier-seq )1

extended-decl-modifier-seq1
extended-decl-modifieropt
extended-decl-modifier-seq extended-decl-modifier

extended-decl-modifier1
thread
naked
dllimport
dllexport

type-specifier
void
char
short
int
__int81
__int161
__int321
__int641
long
float
double
signed
unsigned
_Bool
_Complex
atomic-type-specifier
struct-or-union-specifier
enum-specifier
typedef-name

struct-or-union-specifier
struct-or-union identifier opt{ struct-declaration-list }
struct-or-union identifier

struct-or-union
struct
union

struct-declaration-list
struct-declaration
struct-declaration-list struct-declaration

struct-declaration
specifier-qualifier-listoptstruct-declarator-list ;
static_assert-declaration

specifier-qualifier-list
type-specifier specifier-qualifier-listopt
type-qualifier specifier-qualifier-listopt
alignment-specifier specifier-qualifier-listopt

struct-declarator-list
struct-declarator
struct-declarator-list , struct-declarator

struct-declarator
declarator
declaratoropt : constant-expression

enum-specifier
enum identifier opt{ enumerator-list }
enum identifier {optenumerator-list , }
enum identifier

enumerator-list
enumerator
enumerator-list , enumerator

enumerator
enumeration-constant
enumeration-constant = constant-expression

atomic-type-specifier
_Atomic ( type-name )

type-qualifier
const
restrict
volatile
_Atomic

function-specifier
inline
_Noreturn

alignment-specifier
_Alignas ( type-name )
_Alignas ( constant-expression )

declarator
pointeropt direct-declarator

direct-declarator
identifier
( declarator )
direct-declarator [ type-qualifier-listopt assignment-expressionopt ]
direct-declarator [ static type-qualifier-listopt assignment-expression ]
direct-declarator [ type-qualifier-list static assignment-expression ]
direct-declarator [ type-qualifier-listopt * ]
direct-declarator ( parameter-type-list )
direct-declarator ( identifier-listopt )3

pointer
* type-qualifier-listopt
*opttype-qualifier-list pointer

type-qualifier-list
type-qualifier
type-qualifier-list type-qualifier

parameter-type-list
parameter-list
parameter-list , ...

parameter-list
parameter-declaration
parameter-list , parameter-declaration

parameter-declaration
declaration-specifiers declarator
declaration-specifiers abstract-declaratoropt

identifier-list:/* 用于旧式声明符 */
identifier
identifier-list , identifier

type-name
specifier-qualifier-list abstract-declaratoropt

abstract-declarator
pointer
pointeropt direct-abstract-declarator

direct-abstract-declarator
( abstract-declarator )
direct-abstract-declarator [ type-qualifier-listopt assignment-expressionopt ]
direct-abstract-declarator [ static type-qualifier-listopt assignment-expression ]
direct-abstract-declarator [ type-qualifier-list static assignment-expression ]
direct-abstract-declarator [ type-qualifier-listopt * ]
direct-abstract-declaratoropt ( parameter-type-listopt )

typedef-name
identifier

initializer
assignment-expression
{ initializer-list }
{ initializer-list , }

initializer-list
designationopt initializer
initializer-list , designationopt initializer

designation
designator-list =

designator-list
designator
designator-list designator

designator
[ constant-expression ]
. identifier

static_assert-declaration
_Static_assert ( constant-expression , string-literal ) ;

1 此语法元素是 Microsoft 专用的。
2 有关这些元素的详细信息,请参阅 __asm__clrcall__stdcall__based__fastcall__thiscall__cdecl__inline__vectorcall
3 此样式已过时。

另请参阅

调用约定
短语结构语法
已过时调用约定