This document covers C++ development practices for Nexen.
- Windows: Visual Studio 2026 (v145)
- Linux: GCC/Clang with C++23 support
- C++23 (
/std:c++23on Windows,-std=c++23on Linux)
- Windows:
/W4(Level 4) - Linux:
-Wall -Wextra -Wpedantic
Static analysis tool for C++ code. Configuration in .clang-tidy.
Single file:
clang-tidy --config-file=.clang-tidy Core/MyFile.cppAll files in a directory:
# Generate compile_commands.json first (CMake or Bear)
clang-tidy -p build Core/*.cppFix issues automatically:
clang-tidy --config-file=.clang-tidy --fix Core/MyFile.cpp| Category | Description |
|---|---|
modernize-* |
C++11/14/17/20/23 modernization |
cppcoreguidelines-* |
C++ Core Guidelines |
performance-* |
Performance improvements |
readability-* |
Code readability |
bugprone-* |
Bug-prone patterns |
clang-analyzer-* |
Static analysis |
In code:
// NOLINTNEXTLINE(modernize-use-nullptr)
void* ptr = 0;
void* ptr2 = 0; // NOLINT(modernize-use-nullptr)In .clang-tidy:
Add to disabled checks list (prefix with -).
Code formatting tool. Configuration in .clang-format.
Format file:
clang-format -i Core/MyFile.cppFormat all files:
find Core Utilities Windows -name "*.cpp" -o -name "*.h" | xargs clang-format -iCheck formatting (CI):
clang-format --dry-run --Werror Core/MyFile.cpp| Element | Style | Example |
|---|---|---|
| Class | PascalCase | NesCpu |
| Function | PascalCase | ExecuteInstruction |
| Variable | camelCase | frameCount |
| Private member | _prefix | _registers |
| Constant | UPPER_CASE | MAX_SPRITES |
| Enum constant | UPPER_CASE | READ_ONLY |
// Prefer unique_ptr for ownership
std::unique_ptr<Console> _console = std::make_unique<Console>();
// shared_ptr when ownership is truly shared
std::shared_ptr<IVideoDevice> _video;// Instead of pointer + size
void ProcessData(std::span<const uint8_t> data) {
for (auto byte : data) { /* ... */ }
}std::optional<uint32_t> FindAddress(const std::string& label) {
auto it = _symbols.find(label);
if (it != _symbols.end()) {
return it->second;
}
return std::nullopt;
}// Instead of sprintf
std::string msg = std::format("Address: ${:04x}", address);// Instead of raw loops
auto count = std::ranges::count_if(sprites, [](auto& s) {
return s.visible;
});See CPP-MODERNIZATION-ROADMAP.md for testing infrastructure plans.
- Windows: Visual Studio Profiler, VTune
- Linux: perf, Valgrind
Enable for debug builds to catch memory errors:
Windows (VS2022+):
<EnableASAN>true</EnableASAN>Linux:
-fsanitize=address -fno-omit-frame-pointer- CPP-MODERNIZATION-ROADMAP.md - Full modernization plan
- CPP-ISSUES-TRACKING.md - GitHub issue tracking