Resource
C++ Coding Standards
16 rules for Unreal Engine C++, each with working code, the reasoning, and the tradeoff.
The standard
16 rules
One per page. Each opens onto the rules in full, worked code, the reasoning, and the tradeoff.
01Guard clauses and assertionsValidate first and return early. Assert only for states correct code cannot reach.02Classes and lifecyclePut the public API first, keep state private, and set up in the right lifecycle hook.03NamingFollow Unreal's prefixes and PascalCase. Put units and boolean meaning in the name.04Functions and resultsMake the signature show what's required, what's optional, and who owns the result.05Const correctness and movesCarry const through the whole read path. Move values the function takes ownership of.06Reflection and Blueprint boundariesExpose the smallest surface the editor and Blueprint need.07Ownership and loadingPick the pointer that says whether it retains, observes, or defers loading.08Headers, IWYU, and modulesInclude what you use, keep headers self-contained, and keep private dependencies private.09Control flowBrace every branch, handle every enum value, and keep conditions near their values.10Modern C++ and containersUse modern C++ where it reads better. Keep Unreal containers in engine-facing code.11Delegates, timers, and deferred workBind deferred callbacks with something that understands the owner's lifetime.12Logging and commentsLog what failed and where. Comment the constraints the code cannot express.13Strings and textUse FName for identifiers, FText for anything a player reads, and FString for manipulation.14Ticking and per-frame workLeave tick disabled by default. Turn it on only for work that genuinely runs every frame.15Editor-only code and dataGuard editor-only code and data so a cooked build compiles without any of it.16Threads and async workTouch UObjects and engine state on the game thread. Move only pure computation off it.
Before you merge
Review checklist
Formatting tools already catch whitespace. This pass is for ownership, runtime behavior, module boundaries, and the API other code ends up depending on.
- The expected path stays shallow and begins after validation.
- Expected failures use ordinary runtime handling, not assertions.
- Every reflected type has the correct Unreal prefix and macro.
- The public class API appears before protected and private implementation.
- Runtime setup uses the lifecycle hook that matches its required context.
- Mutable state is private unless callers are deliberately allowed to change it.
- Boolean function names explain what true means.
- Long parameter lists and behavior booleans have been replaced with named types.
- Read-only methods, parameters, locals, and loops use const.
- UObject references state whether they retain, observe, or defer loading.
- Every reflected
TObjectPtrthat must survive garbage collection is markedUPROPERTY. - Headers compile from their own includes and do not rely on unity builds.
- The matching header is first in each source file, and
.generated.his last in each reflected header. - Public module dependencies appear in public headers. Everything else remains private.
- Deferred callbacks use a binding that understands the owner lifetime.
- Log categories and verbosity make production diagnostics filterable.
- Comments explain caller obligations or constraints that the code cannot express.
Primary references
- Epic C++ Coding StandardNaming, const, modern C++, formatting, physical dependencies, encapsulation, and API design.
- Asserts in Unreal EngineShipping behavior and intended use of the check, verify, and ensure families.
- Objects in Unreal EngineUObject construction, default subobjects, and runtime initialization.
- Object PointersGarbage collection, serialization, loading, networking, and pointer selection.
- Include What You UseSelf-contained headers, matching-header order, PCH behavior, and monolithic includes.
- Unreal Engine ModulesPublic and Private source boundaries and dependency visibility.
- Delegates and Lambda FunctionsBinding types, weak lifetime behavior, and safe execution.
- Logging in UnrealCategories, verbosity, runtime controls, and formatting.
- C++ Core GuidelinesGeneral C++ interface, resource, lifetime, and concurrency guidance used where Unreal does not define a narrower rule.

