RAD Studio
ContentsIndex
PreviousUpNext
Possible Declarations

The range of objects that can be declared includes

  • Variables
  • Functions
  • Classes and class members (C++)
  • Types
  • Structure, union, and enumeration tags
  • Structure members
  • Union members
  • Arrays of other types
  • Enumeration constants
  • Statement labels
  • Preprocessor macros
The full syntax for declarations is shown in Tables 2.1 through 2.3. The recursive nature of the declarator syntax allows complex declarators. You'll probably want to use typedefs to improve legibility. 

In CodeGear C++ declaration syntax., note the restrictions on the number and order of modifiers and qualifiers. Also, the modifiers listed are the only addition to the declarator syntax that are not ANSI C or C++. These modifiers are each discussed in greater detail in Variable Modifiers and Function Modifiers. 

CodeGear C++ declaration syntax  

declaration: 
elaborated-type-specifier:  
<decl-specifiers> <declarator-list>; 
class-key identifier  
asm-declaration 
class-key class-name  
function-declaration 
enum enum-name  
linkage-specification 
class-key: (C++ specific)  
decl-specifier: 
class  
storage-class-specifier 
struct  
type-specifier 
union  
function-specifier 
enum-specifier:  
friend (C++ specific) 
enum <identifier> { <enum-list> }  
typedef 
enum-list:  
decl-specifiers: 
enumerator  
<decl-specifiers> decl-specifier 
enumerator-list , enumerator  
storage-class-specifier: 
enumerator:  
auto 
identifier  
register 
identifier = constant-expression  
static 
constant-expression:  
extern 
conditional-expression  
function-specifier: (C++ specific) 
linkage-specification: (C++ specific)  
inline 
extern string { <declaration-list> }  
virtual 
extern string declaration  
simple-type-name: 
type-specifier:  
class-name 
simple-type-name  
typedef-name 
class-specifier  
boolean 
 
char 
enum-specifier  
short 
elaborated-type-specifier  
int 
const  
__int8 
 
__int16 
 
__int32 
 
__int64 
 
long 
volatile  
signed 
declaration-list:  
unsigned 
declaration  
float 
declaration-list ; declaration  
double 
 
void 
 
declarator-list: 
type-name:  
init-declarator 
type-specifier <abstract-declarator>  
declarator-list , init-declarator 
abstract-declarator:  
init-declarator: 
pointer-operator <abstract-declarator>  
declarator <initializer> 
<abstract-declarator> ( argument-declaration-list )  
declarator: 
<cv-qualifier-list>  
dname 
<abstract-declarator> [ <constant-expression> ]  
modifier-list 
( abstract-declarator )  
pointer-operator declarator 
argument-declaration-list:  
declarator ( parameter-declaration-list )  
<arg-declaration-list>  
<cv-qualifier-list > 
arg-declaration-list , ...  
(The <cv-qualifier-list > is for C++ only.) 
<arg-declaration-list> ... (C++ specific)  
declarator [ <constant-expression> ] 
arg-declaration-list:  
( declarator ) 
argument-declaration  
modifier-list: 
arg-declaration-list , argument-declaration  
modifier 
argument-declaration:  
modifier-list modifier 
decl-specifiers declarator  
modifier: 
decl-specifiers declarator = expression  
__cdecl 
(C++ specific)  
__pascal 
decl-specifiers <abstract-declarator>  
__stdcall 
decl-specifiers <abstract-declarator> = expression  
__fastcall 
(C++ specific)  
function-definition: 
 
function-body: 
 
pointer-operator: 
compound-statement  
  • <cv-qualifier-list>
 
initializer:  
& <cv-qualifier-list> (C++ specific) 
= expression  
class-name :: * <cv-qualifier-list>  
= { initializer-list }  
(C++ specific) 
( expression-list ) (C++ specific)  
cv-qualifier-list: 
initializer-list:  
cv-qualifier <cv-qualifier-list> 
expression  
cv-qualifier 
initializer-list , expression  
const 
{ initializer-list <,> }  
volatile 
 
dname: 
 
name 
 
class-name (C++ specific) 
 
~ class-name (C++ specific) 
 
type-defined-name 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!