← Dolaima← Docs indexC++原文中文

C++

The same interfaces as C, with classes. Good for organising game logic into objects.

How to run it on your phone

vml run examples/cpp/test/sysinfo.cpp

Compiling takes a while (one to two minutes for C, a few seconds for scripting languages). Once the program is running, the gamepad is at the bottom of the screen - the D-pad and the four action buttons are all there. Tap the back arrow in the top-right corner to return to the Shell.

What to know before you write

Examples

FileWhat it shows
app/snake.cppSnake
test/sysinfo.cppDevice information

Also in this folder: app/1945.cpp, app/gorilla.cpp, app/minesweeper.cpp, bgi/demo_bgi.cpp, bgi/test_bgi.cpp, demo/demo_std.cpp, test/libs.cpp, tty/demo_tty.cpp, ui/demo_ui.cpp


The rest of this page is taken straight from the VML source (third_party/vml/VMLPrepares/CppCompiler/): the README covers what this front end supports and how to compile it, and the language reference covers the syntax itself. When upstream changes, regenerating this page brings it up to date.

Language reference

C++ language compiler specification

Version: v1.1 | Date: 2026-07-06 | Revised by: Shenzhen Tanso Intelligent Technology Co., Ltd.

Specification standard

FieldValue
Target standardC++11 subset (ISO/IEC 14882:2011)
Publication year2011
Completeness~95%
MCU completeness~93%
Tests0 (test directory yet to be created)
Updates2026-05-18: corrected the target standard to C++11 (including nullptr/constexpr/override); corrected completeness and test counts

Keywords

All C subset keywords plus the C++ extensions: class new delete this virtual override public private protected namespace using template typename try catch throw typeid dynamic_cast static_cast const_cast reinterpret_cast bool true false nullptr friend operator explicit mutable inline constexpr

Supported features (C++11 subset)

Basic features
Object-oriented
Advanced features
Standard library

Floating-point and 64-bit compile modes

The VML toolchain controls how floating-point values and 64-bit integers are handled through three compile options:

OptionValuesDefaultDescription
--float32hard / soft / nonehardHow 32-bit floating point (float) is handled
--float64hard / soft / nonesoftHow 64-bit floating point (double) is handled
--int64hard / soft / nonesoftHow 64-bit integers (long long) are handled
32-bit floating point (float32)

The 32-bit single-precision floating-point type float in this language is compiled in one of the following modes:

64-bit floating point (double)

The 64-bit double-precision floating-point type double in this language is compiled in one of the following modes:

64-bit integers (int64)

The 64-bit integer type long long in this language is compiled in one of the following modes:

Software simulation libraries

The software simulation libraries above all live in the Lib/shared/ directory. They are written in C and compiled to VML by the C compiler, and every language shares them:

Library filePurposeCore functions
softfloat.cQ15.16 fixed-point 32-bit floating-point simulation__vml_float_add/sub/mul/div/neg/abs/cmp, __vml_int2float/float2int
softdouble.cIEEE 754 double-precision 64-bit floating-point simulation__vml_double_add/sub/mul/div/neg/abs/cmp, __vml_int2double/double2int, __vml_float2double/double2float
softint64.c64-bit integer double-register simulation__vml_i64_add/sub/neg/and/or/xor/not/shl/shr

Precision notes


🆕 String type (v1.65.19)

This language compiler stores strings internally as .wstring (UTF-16LE) by default.

ModeDefault encodingVML directiveSYSCALL output
MCU (default).string (UTF-8).string#1
OS.wstring (UTF-16LE).wstring#391

Predefined macro: VML_WSTRING — defined automatically in OS mode, undefined in MCU mode Output function: OS mode automatically uses shared_print_wstr (converts UTF-16LE to UTF-8 automatically)

// user code can test the encoding with the macro
#ifdef VML_WSTRING
  // the default string is wstring (UTF-16LE)
#else
  // the default string is UTF-8
#endif

🆕 Preprocessor directives (v1.65.19)

The C++ compiler inherits every preprocessor feature of the C compiler:

DirectiveDescription
#param lib("xxx")automatically links the given library
#param path("xxx")adds an include path
#param prefix("xxx")function name prefix (multi-language libraries)

Together with the -D VML_PREFIX=xxx command-line option, the same C/C++ source can generate libraries with different prefixes for different languages. See C_LANGUAGE_SPEC.md for details.

Compiler README

C++11 compiler

Path: VMLPrepares/CppCompiler/ Completeness: ~95% | 🟢 production ready Standard library: Lib/cpp/

Features

Compile modes

MCU mode (default, --mode mcu)

MCU mode is tuned for microcontroller and bare-metal environments (Arduino/STM32/8051 and the like) and automatically skips features that need an operating system.

Skipped (no code is generated when these appear):

Kept (the low-level parts are provided by the BIOS):

OS mode (--mode os, reserved)

OS mode targets environments that have an operating system (embedded Linux, RTOS and so on). It will then support the full set of language features (file system, threads, async, exceptions, reflection and so on).

RAM level
MCU safe-coding tips

Usage

dotnet run --project VMLPrepares/CppCompiler input.Cp -o output.vml

Tests

Test/Cp/ — 0 test files (the test directory is yet to be created)