typedef
Sign in to save'''' is a reserved keyword in the programming languages C, C++, and Objective-C. It is used to create an additional name (alias'') for another data type, but does not create a new type, except in the obscure case of a qualified typedef of an array type where the typedef qualifiers are transferred to the array element type. As such, it is often used to simplify the syntax of declaring complex data structures consisting of struct and union types, although it is also commonly used to provide specific descriptive type names for integer data types of varying sizes.
~15 min read
Article
16 sectionsContents
- Syntax
- Examples
- Documentation use
- Declaration simplification
- Pointers
- Constant pointers
- Structures and structure pointers
- Function pointers
- Arrays
- Type casts
- Usage in C++
- Use with templates
- Other languages
- Usage concerns
- See also
- References
'''' is a reserved keyword in the programming languages C, C++, and Objective-C. It is used to create an additional name (alias) for another data type, but does not create a new type, except in the obscure case of a qualified typedef of an array type where the typedef qualifiers are transferred to the array element type. As such, it is often used to simplify the syntax of declaring complex data structures consisting of struct and union types, although it is also commonly used to provide specific descriptive type names for integer data types of varying sizes.
==Syntax== A typedef declaration'' follows the same syntax as declaring any other C identifier. The keyword typedef itself is a specifier which means that while it typically appears at the start of the declaration, it can also appear after the type specifiers or between two of them.