Possible Declarations
Go Up to Declaration Syntax Index
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 below. The recursive nature of the declarator syntax allows complex declarators. You'll probably want to use typedefs to improve legibility.
In C++Builder 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.
C++Builder declaration syntax
declaration: <decl-specifiers> <declarator-list>; asm-declaration function-definition linkage-specification asm-declaration: __asm <(> string-literal <)> < ; or newline > decl-specifier: storage-class-specifier type-specifier function-specifier friend (C++ specific) typedef decl-specifiers: <decl-specifiers> decl-specifier storage-class-specifier: auto register static extern function-specifier: (C++ specific) inline virtual simple-type-name: class-name typedef-name boolean char short int __int8 __int16 __int32 __int64 long signed unsigned float double void declarator-list: init-declarator declarator-list , init-declarator init-declarator: declarator <initializer> declarator: dname modifier-list pointer-operator declarator declarator ( parameter-declaration-list ) <cv-qualifier-list> (C++ specifiс) declarator [ <constant-expression> ] ( declarator ) modifier-list: modifier modifier-list modifier modifier: __cdecl __pascal __stdcall __fastcall pointer-operator: * <cv-qualifier-list> & <cv-qualifier-list> (C++ specific) class-name :: * <cv-qualifier-list> (C++ specific) cv-qualifier-list: cv-qualifier <cv-qualifier-list> cv-qualifier: const volatile dname: name class-name (C++ specific) ~ class-name (C++ specific) type-defined-name elaborated-type-specifier: class-key identifier class-key class-name enum enum-name class-key: (C++ specific) class struct union enum-specifier: enum <identifier> { <enum-list> } enum-list: enumerator enumerator-list , enumerator enumerator: identifier identifier = constant-expression constant-expression: conditional-expression linkage-specification: (C++ specific) extern string { <declaration-list> } extern string declaration type-specifier: simple-type-name class-specifier enum-specifier elaborated-type-specifier const volatile declaration-list: declaration declaration-list ; declaration type-name: type-specifier <abstract-declarator> abstract-declarator: pointer-operator <abstract-declarator> <abstract-declarator> ( argument-declaration-list ) <cv-qualifier-list> <abstract-declarator> [ <constant-expression> ] ( abstract-declarator ) argument-declaration-list: <arg-declaration-list> arg-declaration-list , ... <arg-declaration-list> ... (C++ specific) arg-declaration-list: argument-declaration arg-declaration-list , argument-declaration argument-declaration: decl-specifiers declarator decl-specifiers declarator = expression (C++ specific) decl-specifiers <abstract-declarator> decl-specifiers <abstract-declarator> = expression (C++ specific) function-definition: <decl-specifiers> declarator <declaration-list> function-body function-body: compound-statement initializer: = expression = { initializer-list } ( expression-list ) (C++ specific) initializer-list: expression initializer-list , expression { initializer-list <,> }