Runtime | Microsoft C

The Microsoft C Runtime (CRT): An In-Depth Guide

Introduction

The Microsoft C Runtime (CRT) is the standard library for the C programming language provided by Microsoft for use with the Microsoft Visual C++ (MSVC) compiler. It serves as the bridge between your high-level C/C++ code and the low-level Windows operating system APIs.

How to avoid it (As a developer):

  • 16-bit Windows (CRT as a static library)
  • Win32 (introduction of DLL-based CRT for memory sharing)
  • C++ exceptions, templates, and STL (MSVC 4.0+)
  • Security-enhanced functions (_s variants like strcpy_s – ISO/IEC TR 24731)
  • 64-bit support (AMD64 and ARM64)
  • Universal CRT (UCRT) – a major redesign for Windows 10 and later.

Versioning: It separates the stable C standard functions (UCRT) from the compiler-specific features (VCRuntime). microsoft c runtime

// The CRT startup routine does something like this (simplified):
void __cdecl mainCRTStartup(void) 
    _initterm(__xc_a, __xc_z);  // Call C++ static constructors
    _initterm(__xi_a, __xi_z);  // Call C initializers
    int result = main(__argc, __argv, _environ);
    exit(result);               // Flushes buffers, calls atexit, etc.

Related Posts

About Author