UE C++ Foundations
Target engine: UE 5.8. APIs below are verified against the 5.8 headers; older forms are listed under "Deprecated — do not use".
This skill covers the C++ layer every Unreal module is built on: reflection macros (UCLASS, UPROPERTY, UFUNCTION, USTRUCT, UENUM, UINTERFACE), containers, delegates, string types, object lifetime and garbage collection, CDO access, and the subsystem family. All of it lives in the Core, CoreUObject and Engine modules (PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine" });). Editor subsystems additionally need EditorSubsystem and UnrealEd in an editor-only module.
Context
Read .agents/ue-project-context.md if it exists (module names, conventions, enabled plugins, GAS/networking setup). Do not stop if it is missing.
Identify the area from the request and the codebase. Ask only when two plausible readings would produce different code.
Reflection Macros
Every reflected type has GENERATED_BODY() as the first line of its body and #include "TypeName.generated.h" as the last include of its header. Every UCLASS in a game module carries the module API macro (MYGAME_API). Specifier parsing is case-insensitive (engine headers use both config=Game and Config=Game). Complete specifier and meta= tables: references/property-specifiers.md [blocked].
UCLASS
UPROPERTY
UFUNCTION
Function libraries, latent and async nodes, WorldContext/DefaultToSelf/ExpandEnumAsExecs and the rest of the Blueprint-facing meta= keys: ue-blueprint-cpp-interop.
USTRUCT, UENUM, UINTERFACE
- A
UDataTablerow type is aUSTRUCTderiving fromFTableRowBase(Engine/DataTable.h); seeue-data-assets-tables. - Initialize every
USTRUCTmember in-class; reflected structs are value types copied freely by the engine. - A polymorphic struct value (any
USTRUCTderived from a base) is stored asFInstancedStructor typedTInstancedStruct<FMyBase>(StructUtils/InstancedStruct.h, moduleCoreUObject). UINTERFACEpairs aUMyThing : UInterfacestub with anIMyThingclass; specifier table and a native example are in references/property-specifiers.md [blocked]. Blueprint-implementable interfaces belong toue-blueprint-cpp-interop.
Containers
Full API, iteration and performance notes: references/container-patterns.md [blocked]. Containers of UObject pointers are GC-tracked only as UPROPERTY() TArray<TObjectPtr<T>> (likewise TMap/TSet).
TVariant
Delegates
All declaration macros, binding methods and payload rules: references/delegate-patterns.md [blocked].
The owner broadcasts with OnHealthChanged.Broadcast(CurrentHealth, MaxHealth);. Both classes in full: references/delegate-patterns.md [blocked].
Single delegates bind with BindUObject, BindSP, BindRaw, BindStatic, BindLambda, BindWeakLambda(this, ...) and fire with ExecuteIfBound(...). For a lambda that captures this, prefer AddWeakLambda/BindWeakLambda so the binding dies with the object.
String Types
Object Lifetime and Pointers
The garbage collector keeps alive every UObject reachable from a root through reflected (UPROPERTY) references, FGCObject referencers, TStrongObjectPtr and rooted objects. A pointer the GC cannot see may dangle.
Non-UObject classes that hold UObjects derive from FGCObject and report them through TObjectPtr members; the raw UObject* overloads of AddReferencedObject(s) are deprecated and unsafe with incremental GC.
CDO Access and Non-Null Parameters
UClass::ClassDefaultObject is deprecated for direct access. TNotNull<T*> converts implicitly to T*; keep T* where null is a meaningful value.
Subsystems
Auto-instanced singletons owned by an engine object; no manual rooting. Override Initialize(FSubsystemCollectionBase&)/Deinitialize(); call Collection.InitializeDependency<UMyOtherSubsystem>() inside Initialize when ordering matters; return false from ShouldCreateSubsystem(UObject* Outer) const to opt out.
UWorldSubsystem also offers PostInitialize(), OnWorldBeginPlay(UWorld& InWorld), OnWorldEndPlay(UWorld& InWorld) and OnWorldComponentsUpdated(UWorld& World) overrides; ULocalPlayerSubsystem::GetLocalPlayer<T>() and UGameInstanceSubsystem::GetGameInstance() return the owner.
Replicated Properties
Both the specifier and the GetLifetimeReplicatedProps entry are required. Conditions (COND_*), RPC rules, push model and Iris: ue-networking-replication.
Logging
Verbosities (Logging/LogVerbosity.h): Fatal, Error, Warning, Display, Log, Verbose, VeryVerbose. Display prints to the console and the log file; Log goes to the log file only. Shipping builds compile UE_LOG out unless the target sets bUseLoggingInShipping = true. Categories, structured logging (UE_LOGFMT), runtime verbosity control and profiling: ue-testing-debugging.
Conditional Compilation Guards
Deprecated — do not use
Common Mistakes
Raw UObject* member without UPROPERTY — dangling after GC:
Mutating a TArray inside ranged-for — iterator invalidation:
TSharedPtr around a UObject — two owners, one crash: UObjects are owned by the GC; use TObjectPtr, TWeakObjectPtr or TStrongObjectPtr.
.generated.h not the last include, or MYGAME_API missing: UnrealHeaderTool rejects the header; the missing API macro surfaces later as LNK2019 from other modules.
AddDynamic bound to a non-UFUNCTION: the reflection lookup fails at runtime and the handler never runs; mark it UFUNCTION().
UPROPERTY/UFUNCTION written above a .cpp definition: UnrealHeaderTool only parses headers; the macro is silently ignored. Put it on the declaration inside the class body.
BlueprintNativeEvent without Name_Implementation: unresolved external at link time. Declare virtual void Name_Implementation(...) and define it.
UTickableWorldSubsystem::Initialize/Deinitialize override without Super::: the tickable registration lives in the base implementation; the subsystem never ticks.
Reading ClassDefaultObject directly: deprecated and about to become private; use GetDefault<T>().
Log verbosity "not showing up": Log is file-only by design; use Display for console output.
Related Skills
ue-actor-component-architecture— AActor/UActorComponent lifecycle, spawning, tick groups, component setupue-module-build-system— Build.cs, module dependencies, API export macros, include paths, PCHue-testing-debugging— log categories and verbosity, structured logging, automation tests, profilingue-networking-replication— DOREPLIFETIME conditions, RPC rules, push model, Irisue-blueprint-cpp-interop— UBlueprintFunctionLibrary, latent and async actions, Blueprint-implementable- Also relevant:
ue-data-assets-tables,ue-animation-system,ue-async-threading,ue-audio-system,ue-editor-tools,ue-gameplay-abilities,ue-gameplay-framework,ue-gameplay-tags-messaging,ue-input-system,ue-mass-entity,ue-materials-rendering,ue-serialization-savegames,ue-state-trees,ue-ui-umg-slate,ue-world-level-streaming


