Genyleap/Docs
Entwicklungs-Stack-Leitfaden · C++

Moderne C++-Entwicklung.

Eine produktionsorientierte C++26-first-Umgebung mit projekteigenen Modulen, expliziten Fehlerverträgen, RAII, target-basiertem CMake, Ninja und plattformnativen Toolchains. C++23 bleibt der Kompatibilitätspfad, wenn Compiler oder Standardbibliothek für ausgewählte C++26-Funktionen noch nicht bereit sind.

Primary C++26 Compatibility C++23 Entwicklung CMake 3.30+ · Ninja 1.11+ Targets Desktop · Mobile · Web

Engineering-Baseline.

AreaDefaultRule
LanguageC++26Bevorzuge den aktuellen Sprachpfad; nutze C++23 nur, wenn die konkrete Toolchain-Unterstützung es erfordert.
Project boundariesC++ modulesNew project-owned production boundaries use .cppm modules by default.
Standard libraryMinimal headersUse normal standard headers in the global module fragment; do not depend on experimental import std;.
Fehlerstd::expectedMache behebbare Fehler zum Teil des API-Vertrags, statt sie hinter Sentinel-Werten zu verstecken.
Console outputstd::print / std::printlnBevorzuge moderne formatierte Ausgabe gegenüber neuen iostream-Einfügeketten.
Build modelTarget-based CMakeHalte Compile-Features, Quellen, Definitionen und Abhängigkeiten am jeweils besitzenden Target.
GeneratorNinjaVerwende getrennte Build-Bäume pro Compiler, Konfiguration und Target.

Beginne mit Modulen, nicht mit Headern.

Projekteigene Grenzen sollen Verantwortlichkeiten direkt ausdrücken. Exportiere Deklarationen aus Modul-Interfaces, halte nichttriviale Implementierung in Implementation Units und isoliere Plattform- oder Drittanbietercode hinter expliziten Adaptergrenzen.

C++ module interfacesrc/greeting/greeting.cppm
module;

#include <expected>
#include <string>
#include <string_view>

export module genyleap.greeting;

export namespace genyleap::greeting {

enum class GreetingError {
    EmptyName
};

[[nodiscard]] auto makeGreeting(std::string_view name)
    -> std::expected<std::string, GreetingError>;

}
C++ implementation unitsrc/greeting/greeting.cpp
module;

#include <expected>
#include <format>
#include <string>
#include <string_view>

module genyleap.greeting;

namespace genyleap::greeting {

auto makeGreeting(std::string_view name)
    -> std::expected<std::string, GreetingError>
{
    if (name.empty()) {
        return std::unexpected {GreetingError::EmptyName};
    }

    return std::format("Hello, {}.", name);
}

}
Composition rootsrc/main.cpp
#include <print>

import genyleap.greeting;

int main()
{
    const auto greeting = genyleap::greeting::makeGreeting("Genyleap");

    if (!greeting) {
        std::println("Unable to create greeting.");
        return 1;
    }

    std::println("{}", *greeting);
    return 0;
}

Target-basiertes CMake mit Modul-Scanning.

Halte Sprachstandard, Modul-Dateisatz und Abhängigkeitsgraph am Target. Verwende keine globalen Compilerflags oder projektweiten Include-Verzeichnisse, um klassische Header-Architektur zu simulieren.

CMakeCMakeLists.txt
cmake_minimum_required(VERSION 3.30)

project(GenyleapHello
    VERSION 0.1.0
    LANGUAGES CXX
)

add_library(genyleap_greeting)

target_compile_features(genyleap_greeting
    PUBLIC
        cxx_std_26
)

target_sources(genyleap_greeting
    PUBLIC
        FILE_SET CXX_MODULES
        FILES
            src/greeting/greeting.cppm
    PRIVATE
        src/greeting/greeting.cpp
)

set_property(
    TARGET genyleap_greeting
    PROPERTY CXX_SCAN_FOR_MODULES ON
)

add_executable(genyleap_hello
    src/main.cpp
)

target_link_libraries(genyleap_hello
    PRIVATE
        genyleap_greeting
)

target_compile_features(genyleap_hello
    PRIVATE
        cxx_std_26
)
ShellConfigure · build · test
cmake -S . -B build/dev -G Ninja \
  -DCMAKE_BUILD_TYPE=Debug

cmake --build build/dev --parallel

ctest --test-dir build/dev \
  --output-on-failure \
  --no-tests=error

Plattform-Toolchains.

Die C++-Architektur bleibt portabel; Compiler, SDK, Linker, Packaging und Runtime bleiben explizite Plattformgrenzen. Einen konfigurierten CMake-Baum nach Wechsel von Compiler oder Target-SDK niemals wiederverwenden.

macOS.

Installiere das vollständige Xcode für Apple SDK und Plattformwerkzeuge. Apple Clang ist der native Standardcompiler; Upstream-LLVM kann parallel installiert werden, wenn neuere Compilerfunktionen oder Diagnosen nötig sind.

ShellInstall and verify
sudo xcode-select --switch /Applications/Xcode.app
sudo xcodebuild -license accept

brew install cmake ninja llvm

xcrun clang++ --version
cmake --version
ninja --version
xcrun --show-sdk-path
Apple Clang nicht global ersetzen.

Select upstream LLVM per build when needed; Apple SDK integration and upstream language experimentation are separate concerns.

Linux.

Halte GCC und Clang verfügbar, wenn Portabilität wichtig ist. Konfiguriere für jeden Compiler ein eigenes Build-Verzeichnis und verifiziere Modul-Unterstützung mit der tatsächlichen CMake/Compiler/Generator-Kombination statt nur anhand von Versionsnummern.

ShellUbuntu / Debian baseline
sudo apt update
sudo apt install -y \
  build-essential \
  clang \
  lld \
  cmake \
  ninja-build \
  gdb
ShellSeparate compiler builds
cmake -S . -B build/gcc -G Ninja \
  -DCMAKE_CXX_COMPILER=g++

cmake -S . -B build/clang -G Ninja \
  -DCMAKE_CXX_COMPILER=clang++

Windows.

Use Visual Studio Build Tools with the C++ workload for the Windows SDK and MSVC ABI. Add LLVM when you want clang-cl diagnostics while retaining MSVC-compatible platform integration.

PowerShellInstall toolchains
winget install --id Microsoft.VisualStudio.2022.BuildTools `
  --override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

winget install --id Kitware.CMake
winget install --id Ninja-build.Ninja
winget install --id LLVM.LLVM
Developer PowerShell verwenden.

Compiler, Linker und Windows-SDK-Umgebung von MSVC müssen vor der CMake-Konfiguration initialisiert sein.

Android.

Use the Android NDK's Clang toolchain and CMake toolchain file rather than treating Android as a normal Linux desktop build. For projects that also use the current Qt baseline, the compatibility manifest currently resolves NDK r27c (27.2.12479018).

CMakeNative Android shape
cmake -S . -B build/android-arm64 -G Ninja \
  -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28

cmake --build build/android-arm64 --parallel

Halte Android-spezifischen JNI-, Lifecycle-, Storage- und Berechtigungscode hinter Adaptern, damit Domain- und Application-Module normales C++ bleiben.

iOS.

Use Xcode 16 or newer for the current Qt compatibility profile, and treat Apple frameworks, entitlements, signing and bundle resources as platform boundaries. Device and simulator builds are distinct targets even when they share application modules.

ShellInspect active Apple SDKs
xcodebuild -version
xcrun --sdk iphoneos --show-sdk-path
xcrun --sdk iphonesimulator --show-sdk-path
xcrun --sdk iphoneos clang++ --version

WebAssembly.

Use Emscripten when the target runtime is the browser. For the current Qt compatibility profile, Emscripten 5.0.5 is pinned automatically from upstream Qt documentation; a standalone C++/WASM project may intentionally choose a newer SDK after its own verification.

POSIX shellPin an emsdk toolchain
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk

./emsdk install 5.0.5./emsdk activate 5.0.5
source ./emsdk_env.sh
em++ --version
PowerShellWindows activation
git clone https://github.com/emscripten-core/emsdk.git
Set-Location emsdk

.\emsdk.bat install 5.0.5.\emsdk.bat activate 5.0.5
.\emsdk_env.ps1
em++ --version

Browser-Threading, SIMD, Dateisystemzugriff und Netzwerkverhalten sind Runtime-Beschränkungen, nicht nur Compiler-Schalter. Modelliere sie als Target-Fähigkeiten und verifiziere sie in der Browserkonfiguration, die ausgeliefert wird.

Diagnosen sind Teil der Entwicklungsumgebung.

Compile-Time-Korrektheit ist nur eine Ebene. Halte Sanitizer- und Static-Analysis-Builds von Anfang an verfügbar, statt sie erst nach schwer reproduzierbaren Fehlern hinzuzufügen.

WerkzeugVerwendungRecommendation
ASanMemory safety failuresDebug and CI where supported
UBSanUndefined behaviorPair with ASan in a dedicated diagnostic build
TSanData racesSeparate build because instrumentation changes runtime behavior
clang-tidyStatic analysis and modernizationEditor plus CI on changed production surfaces
CMakeTarget-local sanitizer example
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
    target_compile_options(genyleap_greeting PRIVATE
        -fsanitize=address,undefined
        -fno-omit-frame-pointer
    )

    target_link_options(genyleap_greeting PRIVATE
        -fsanitize=address,undefined
    )
endif()

Boost is part of the native foundation.

Use the C++ standard library first when it cleanly provides the required facility, then use Boost for capabilities that remain stronger or broader there. Keep Boost dependencies target-local, architecture-specific when compiled, and visible through modern CMake imported targets.

Benutzeranwendungen: bewusst zu Qt wechseln.

Für neue grafische Anwendungen im Genyleap-Stil besteht der Standard-UI-Stack aus Qt Quick, QML und Qt Quick Controls über modulbasiertem C++-Application/Domain-Code. Die UI ist ein Adapter und besitzt keine duplizierte Geschäftslogik.