Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Alibaba MNN RapidJSON Stdint

From Leeroopedia


Knowledge Sources
Domains JSON_Parsing, Compatibility
Last Updated 2026-02-10 12:00 GMT

Overview

3rd_party/rapidjson/msinttypes/stdint.h (300 lines) provides an ISO C99-compliant <stdint.h> implementation for older Microsoft Visual C++ compilers. This vendored header ensures that fixed-width integer types (int8_t, uint32_t, int64_t, etc.) are available when building RapidJSON (and Alibaba MNN) on Windows platforms with MSVC versions prior to Visual Studio 2010.

Usage note: Vendored dependency used internally by MNN for JSON configuration parsing (model configs, LLM configs). Not directly imported by end users.

Conditional Compilation

The header is MSVC-only and uses version detection to determine which definitions are needed:

#ifndef _MSC_VER
#error "Use this header only with Microsoft Visual C++ compilers!"
#endif

// MSVC 2010+ has its own stdint.h, but INT64_C() generates warnings
#if _MSC_VER >= 1600
#include <stdint.h>
// Redefine constant macros to suppress warnings
#undef INT8_C
#undef INT16_C
#undef INT32_C
#undef INT64_C
// ... redefinitions ...
#else
// Full type definitions for older MSVC
#endif

Defined Types

Exact-Width Integer Types

Type Width MSVC Mapping
int8_t 8-bit signed signed __int8
uint8_t 8-bit unsigned unsigned __int8
int16_t 16-bit signed signed __int16
uint16_t 16-bit unsigned unsigned __int16
int32_t 32-bit signed signed __int32
uint32_t 32-bit unsigned unsigned __int32
int64_t 64-bit signed signed __int64
uint64_t 64-bit unsigned unsigned __int64

Minimum-Width Types

Types like int_least8_t, int_least16_t, int_least32_t, int_least64_t and their unsigned counterparts.

Fastest Minimum-Width Types

Types like int_fast8_t, int_fast16_t, etc., mapped to the fastest available integer type of at least that width.

Maximum-Width and Pointer Types

  • intmax_t / uintmax_t -- mapped to 64-bit integers
  • intptr_t / uintptr_t -- pointer-width integers (32 or 64 bit depending on platform)

Limit and Constant Macros

The header defines limit macros (e.g., INT8_MIN, INT8_MAX, UINT8_MAX, INT64_MIN, INT64_MAX) and integer constant macros (e.g., INT8_C(val), UINT64_C(val)) following the C99 specification. These are conditionally defined based on __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS.

MSVC Version Notes

  • MSVC < 1600 (VS 2010) -- All types and macros are fully defined by this header
  • MSVC >= 1600 -- Defers to the native <stdint.h> but overrides the INT64_C/UINT64_C macros to suppress compiler warning C4307

License

BSD 3-Clause License. Copyright (c) 2006-2013 Alexander Chemeris. Modified by THL A29 Limited (Tencent Modifications), Copyright (C) 2015.

See Also

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment