This project uses clang-format to maintain consistent code formatting.
Install the pre-commit hook to automatically format your code:
./setup-hooks.shThis will:
- ✅ Automatically format C++ files before each commit
- ✅ Prevent CI failures due to formatting issues
- ✅ Use the project's
.clang-formatconfiguration
If you prefer manual control:
# Format ALL files in repository (recommended after cloning)
./format-all.sh
# Format all files via CMake
cmake --build build --target format
# Check formatting without changes
cmake --build build --target format-check
# Format specific file
clang-format -i path/to/file.hpp- clang-format: Install via your package manager
- Ubuntu/Debian:
sudo apt install clang-format - macOS:
brew install clang-format - Windows: Install LLVM/Clang tools
- Ubuntu/Debian:
# Bootstrap automatically detects and configures everything
./bootstrap_cmake.sh # Linux/macOS
bootstrap_cmake.bat # Windows
# Manual build
cmake --preset conan-release # or conan-debug
cmake --build --preset conan-release --parallel
# Test
cd build/build && ./utf_strings-tests
# Benchmark
cd build/build && ./utf_strings-benchFor specific testing scenarios or performance optimization:
# Development build (fast iteration)
cmake --preset conan-debug \
-DCOMPILER_TYPE=CLANG \
-DUSE_LTO=OFF \
-DUSE_NATIVE_ARCH=OFF \
-DENABLE_SHARED_LIBRARY=OFF
# Performance testing build
cmake --preset conan-release \
-DCOMPILER_TYPE=CLANG \
-DUSE_LTO=ON \
-DUSE_NATIVE_ARCH=ON \
-DUSE_LIBC_PLUS_PLUS=ON \
-DENABLE_SHARED_LIBRARY=ON
# Cross-platform compatibility testing
cmake --preset conan-release \
-DCOMPILER_TYPE=GCC \
-DUSE_LTO=ON \
-DUSE_NATIVE_ARCH=OFF \
-DENABLE_SHARED_LIBRARY=ON| Flag | Values | Purpose |
|---|---|---|
COMPILER_TYPE |
GCC|CLANG|MSVC |
Explicit compiler identification for debugging |
USE_LTO |
ON|OFF |
Enable/disable Link Time Optimization |
USE_NATIVE_ARCH |
ON|OFF |
Enable/disable native CPU optimization |
USE_MSVC_LTO |
ON|OFF |
MSVC-specific LTO flags (/LTCG, /GL) |
USE_LIBC_PLUS_PLUS |
ON|OFF |
Use libc++ instead of libstdc++ (Clang only) |
ENABLE_SHARED_LIBRARY |
ON|OFF |
Build shared libraries |
- Follow the
.clang-formatconfiguration in the repository root - Use C++23 features where appropriate with fallbacks for compatibility
- Prefer standard library functions over platform-specific alternatives
- Write clear, self-documenting code with appropriate comments
Before submitting any changes, review your code against our Code Review Guidelines:
- Security Analysis: No undefined behavior, memory safety issues, or vulnerabilities
- Performance Analysis: Efficient algorithms, no unnecessary allocations
- Correctness: Edge cases handled, proper error handling, const correctness
- C++ Guidelines: RAII, exception safety, modern C++23 features used appropriately
- Design Quality: Consistent API, proper abstraction levels, clear naming
- Documentation: Adequate comments, API docs, up-to-date examples
- Test Coverage: Comprehensive unit tests including edge cases
Every change must meet:
- 🔴 Zero Critical Issues: No security vulnerabilities, UB, or crashes
- 🟡 Minimal Important Issues: Address performance and correctness concerns
- ✅ Production Ready: Code must be deployable to production
See CODE_REVIEW_GUIDELINES.md for complete review parameters.
- Pre-Push Review: Complete comprehensive code review using guidelines above
- Build Verification: Ensure changes build successfully across all configurations
- Test Validation: Run full test suite to ensure functionality is preserved
- Code Formatting: Pre-commit hook will automatically format your code
- Submit PR: Create pull request with clear description referencing review checklist
The project runs comprehensive CI tests with compiler-specific optimizations:
- Linux GCC 13: Production-optimized builds with LTO and native arch optimization
- Linux Clang 18: Development builds with libstdc++ and performance builds with libc++
- Windows MSVC 2022: Full optimization with
/LTCGand/GLflags - Windows Clang-CL 16+: Clang optimization without MSVC-specific flags
- Unit Tests: GoogleTest with comprehensive UTF-8/16/32 coverage
- Sanitizer Testing: AddressSanitizer, UndefinedBehaviorSanitizer, ThreadSanitizer (Clang)
- Fuzz Testing: libFuzzer-based testing for all UTF encodings (Clang)
- Performance Testing: Automated benchmarking with flame graph generation
- Security Analysis: CodeQL static analysis and security hardening validation
Each compiler uses optimized configuration flags:
- GCC:
-O3 -march=native -flto -ftree-vectorizewith security hardening - Clang:
-O3 -march=native -flto -fvectorizewith optional libc++ - MSVC:
/O2 /GL /LTCG /arch:AVX2with security flags - Clang-CL: Clang optimizations without MSVC-specific flags
All builds include:
- Comprehensive warning flags with
-Werror//WX - Code formatting checks with clang-format
- Memory safety validation with sanitizers
- Performance regression detection
- Cross-platform compatibility verification
Your pull request must pass all CI checks before merging. The CI automatically tests your changes across all supported compiler and platform combinations.
This project includes context files to improve AI assistant interactions:
Context Files Available:
.ai-context- Comprehensive project overview and guidelines.copilot-instructions.md- GitHub Copilot-specific patterns
Best Practices:
- Reference project context: "Use the coding patterns from .ai-context"
- Specify C++23 requirements: "Follow C++23 standards and UTF handling patterns"
- Request comprehensive testing: "Include unit tests and consider fuzz testing scenarios"
- Mention performance: "Consider performance implications and benchmarking"
Effective Prompts:
# For new features
"Generate a UTF-16 to UTF-8 converter following the UTF Strings project context and C++23 patterns"
# For optimization
"Optimize this UTF processing function for performance, considering SIMD and the project's benchmarking approach"
# For testing
"Create comprehensive tests for this UTF validation function, including edge cases and invalid sequences"
# For debugging
"Help debug this endianness issue in UTF-32 conversion, using the project's endian policy patterns"
Code Generation Guidelines:
- Always use C++23 features appropriately
- Follow project naming conventions (snake_case functions, PascalCase types)
- Include proper error handling and input validation
- Consider endianness for multi-byte encodings
- Add appropriate documentation comments
- Create corresponding unit tests
The AI context ensures consistent, high-quality assistance across ChatGPT, Claude, and GitHub Copilot! 🚀