Skip to main content

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.

The Microsoft C compiler (MSVC) implements the C programming language as defined by the ISO/IEC standards, with additional Microsoft-specific extensions. The C Language Reference in this documentation describes the C language as it exists in Visual Studio, and is organized after the ANSI C standard (C89/C90) while adding coverage of C99, C11, and C17 features that MSVC has adopted over time. Understanding which standard is in effect for your project is the first step toward writing portable, conformant C code.

ANSI/ISO Conformance

Microsoft C conforms to the standard for the C language as set forth in the 9899:1990 edition of the ANSI C standard (commonly called C89 or C90). Microsoft extensions to the ANSI C standard are noted throughout this reference. Because extensions are not part of the ANSI C standard, their use may restrict portability between systems. By default, Microsoft extensions are enabled. To disable them and compile in strict ANSI mode, use the /Za compiler option. With /Za, all non-ANSI code generates errors or warnings. To re-enable extensions explicitly, use /Ze (the default behavior).
Using /Za disables many convenient Microsoft-specific features. For most Windows application code, leaving extensions enabled (the default /Ze behavior) is recommended. For maximum portability, target a specific ISO standard using /std:c11 or /std:c17 rather than relying on /Za.

C11 and C17 Support

Visual Studio 2019 version 16.8 introduced support for C11 (/std:c11) and C17 (/std:c17) language standards. The conformant preprocessor (/Zc:preprocessor) is automatically enabled when either of these modes is selected.
Enables C11 conformance. The macro __STDC_VERSION__ expands to 201112L. Key C11 features include:
  • _Static_assert for compile-time assertions
  • Anonymous structs and unions
  • _Noreturn function specifier
  • _Alignas / _Alignof alignment specifiers
  • _Generic type-generic expressions
// C11 static assertion
_Static_assert(sizeof(int) == 4, "int must be 4 bytes");

// C11 _Generic selection
#define type_name(x) _Generic((x), \
    int:   "int",                  \
    float: "float",                \
    default: "other")

int main(void) {
    int n = 42;
    printf("%s\n", type_name(n));  // prints "int"
    return 0;
}

Optional C11/C17 Features Not Supported

MSVC defines several __STDC_NO_* macros to indicate omitted optional library components when compiling under C11 or C17:
MacroMeaning
__STDC_NO_ATOMICS__Atomic operations (<stdatomic.h>) not supported
__STDC_NO_COMPLEX__Complex arithmetic (<complex.h>) not supported
__STDC_NO_THREADS__Standard threads (<threads.h>) not supported
__STDC_NO_VLA__Variable-length arrays not supported

Microsoft-Specific Extensions

Even in standard modes, MSVC provides many extensions over and above what ISO C requires. These include:
  • Microsoft-specific calling conventions: __cdecl, __stdcall, __fastcall, __vectorcall
  • Structured Exception Handling (SEH) with __try, __except, __finally
  • Compiler intrinsics for direct hardware access
  • __declspec modifiers for DLL import/export, alignment, deprecated annotations, and more
  • The __pragma keyword for embedding pragmas in macro definitions
Code that uses Microsoft-specific extensions may not compile on other C compilers. When writing portable code, guard extension usage with #ifdef _MSC_VER or similar preprocessor checks.

Topics Covered in This Reference

This C Language Reference is organized into the following major sections:
Covers the fundamental lexical building blocks of C programs — tokens, keywords, identifiers, constants, string literals, operators, and punctuation. This section explains how the MSVC compiler tokenizes source text and evaluates lexical elements in accordance with ANSI C syntax.
Covers the full type system: fundamental types (int, char, float, double, _Bool), type specifiers, type qualifiers (const, volatile, restrict), storage-class specifiers (auto, extern, static, register), struct and union declarations, enumeration types, typedef declarations, and extended MSVC storage-class attributes.
Covers all C operators, their precedence and associativity, usual arithmetic conversions, implicit type conversions, assignment operators, compound assignment, and constant expressions.
Covers expression statements, compound statements (blocks), selection statements (if, switch), iteration statements (for, while, do-while), jump statements (break, continue, return, goto), and labeled statements.
Covers function declarations, definitions, calling conventions, inline functions, variadic functions (va_list, va_start, va_arg, va_end), DLL import/export functions, and function pointers.
Includes reference tables for ASCII character sets, trigraphs, escape sequences, integer limits, floating-point limits, and operator precedence.

See Also

Build docs developers (and LLMs) love