C provides a standard set of fundamental data types from which all other types are derived. In MSVC, every variable and function must be declared before it can be used; those declarations establish the type, storage class, and linkage of the named entity. You can also create new named types — called derived types — by basing them on types already defined in the language. This page covers the full type system available in Microsoft C, from primitive scalars through aggregates and user-defined type names.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MicrosoftDocs/cpp-docs/llms.txt
Use this file to discover all available pages before exploring further.
Fundamental Type Specifiers
Type specifiers in declarations define the type of a variable or function. The keywords recognized by the MSVC C compiler as type specifiers are:| Specifier | Description |
|---|---|
void | No value; used for functions that return nothing, empty parameter lists, and generic pointers |
char | Single byte, typically used to hold a character; may be signed or unsigned depending on /J |
short | Short integer, at least 16 bits |
int | Default integer type, at least 16 bits (32 bits on all MSVC targets) |
long | At least 32 bits |
long long | At least 64 bits |
float | Single-precision floating point (32 bits) |
double | Double-precision floating point (64 bits) |
long double | Same as double in MSVC (64 bits) |
signed | Explicit signed modifier; signed alone means signed int |
unsigned | Unsigned modifier; unsigned alone means unsigned int |
_Bool | Boolean type (C99+); holds 0 or 1 |
The Microsoft C compiler no longer accepts implicit
int declarations (where the type specifier is omitted). Every declaration must include an explicit type specifier. Type short and type int are treated as distinct types, conforming to ANSI requirements.Signed and Unsigned Variants
Thesigned and unsigned keywords can precede any integral type except enum. When used alone they are understood as signed int and unsigned int respectively. For example:
The void Type
The void keyword serves three distinct roles in C:
- Function return type — declares a function that returns no value:
void log_message(const char *msg); - Empty parameter list —
voidinside parentheses means the function accepts no arguments:int get_count(void); - Generic pointer —
void *is a pointer to an unspecified type, used in allocators and generic APIs.
Storage Sizes
The storage size of each basic type on MSVC (all platforms) is fixed:Type Qualifiers
Type qualifiers add semantic properties to a declaration. The qualifiersconst, volatile, and restrict can appear with any type specifier but can appear only once per declaration.
- const
- volatile
- restrict
The
const qualifier declares an object as non-modifiable. The compiler may place const objects in read-only memory and will warn or error on any write attempt.const is especially useful for function parameters to signal that the function does not modify the pointed-to object:Typedef Declarations
Atypedef declaration creates a synonym for an existing type. It is interpreted like an ordinary variable declaration, except that the identifier becomes the new type name rather than a variable name.
Struct and Union Declarations
Structures (struct) group heterogeneous members into a single named type. Unions (union) allow different members to share the same storage.
Bit Fields
C allows members of astruct to be declared as bit fields, specifying an exact number of bits:
Enumeration Types
An enumeration (enum) defines a set of named integer constants. In ANSI C, enumerator values always have type int.
Enumeration identifiers live in the same namespace as ordinary variable identifiers. They must be distinct from other identifiers in the same scope. Enumeration tags (the name after
enum) must also be distinct from other struct, union, and enum tags.Storage-Class Specifiers
Storage-class specifiers control the lifetime and linkage of variables and functions:| Specifier | Scope | Lifetime | Linkage |
|---|---|---|---|
auto | Block | Until end of block | None (local) |
register | Block | Until end of block | None (hints CPU register) |
static | Block or file | Program lifetime | Internal (file scope only) |
extern | Any | Program lifetime | External |