1. Home
  2. UE5 Compilation Errors
  3. UE5 C++ Compilation Error...
  4. C2059: Syntax Error – Token in UE5

C2059: Syntax Error – Token in UE5

What It Means & How to Fix It


🧠 Why You’re Seeing This Error

C2059 is a generic syntax error — the compiler hit a symbol or keyword (called a token) it didn’t expect. It usually points to:

  • A missing semicolon, brace, or parenthesis
  • A malformed macro, enum, or function signature
  • A stray character from a copy-paste or bad refactor

In UE5, this often appears after a broken USTRUCT, UCLASS, UENUM, or a misused macro like GENERATED_BODY().


💥 Example Error Message

error C2059: syntax error: ')'

🛠️ Example Code

USTRUCT()
struct FMyData
{
GENERATED_BODY()

int32 Value(100); // ❌ C2059: syntax error
};

✅ How to Fix C2059 in UE5 – Step-by-Step


✔️ 1. Check for Incorrect Initializers in Structs

Wrong:

int32 Value(100); // ❌ Looks like a function declaration

Fix:

int32 Value = 100; // ✅ Proper variable initialization

✔️ 2. Make Sure You Closed All Brackets and Braces

A missing ) or } earlier in your file can trigger this error way later.

Use Ctrl+K, Ctrl+D in Visual Studio to auto-format and spot problems.


✔️ 3. Watch Out for Macro Errors

If you forget GENERATED_BODY() or mistype USTRUCT(), UE5’s meta system breaks, and you’ll get mysterious C2059s.


✔️ 4. Avoid Using Commas in Wrong Places (Especially in Enums)

Wrong:

UENUM()
enum class EMyType
{
OptionA,
OptionB,
, // ❌ C2059
};

✅ Summary: How to Fix C2059 in UE5

CauseFix Example
Wrong initializer syntaxUse = instead of () for member variables
Missing semicolon or bracketClose }, ), or ] properly
Broken macro or metadataCheck for USTRUCT(), GENERATED_BODY(), etc.
Comma or symbol in wrong placeRemove stray characters or incomplete lines
Was this article helpful to you? Yes No

How can we help?