C2275: Illegal Use of This Type as an Expression in Unreal Engine 5 (UE5 C++) – What It Means & How to Fix It
Why You’re Seeing This Error
The C2275
error means the compiler thinks you’re trying to use a type name as if it were a variable or expression — which usually means:
- You used a type name in the wrong place (like calling
FVector
without declaring a variable) - You forgot a type like
int32
when declaring a variable - You’re using a custom struct or class without including its header
- The syntax is invalid — maybe you’re missing parentheses, commas, or semicolons
In Unreal Engine 5, this often happens when using Unreal types (FVector
, FString
, etc.) without proper context, or when defining variables without a type keyword.
Example Error Message
error C2275: 'FVector': illegal use of this type as an expression
Example Code
void AMyActor::BeginPlay()
{
FVector; //C2275: illegal use of this type as an expression
}
How to Fix C2275 UE5 – Step-by-Step
1. Make Sure You’re Declaring a Variable, Not Just Typing a Type
Unreal types like FVector
, FString
, int32
, etc. need a variable name and often an initializer.
Fix:
FVector Location = GetActorLocation(); //Correct use of FVector
2. Avoid Using Types as Standalone Statements
This won’t work:
FVector; //Invalid — not a complete statement
This will:
FVector MyLocation; //Declaring a variable
3. Include Headers for Custom Types or UE Types
If you’re using a custom struct or a UE5 class (like FMyData
or FMyStruct
) without including the correct header, the compiler gets confused.
Fix:
#include "MyStruct.h" //Always include your custom types
4. Make Sure You Didn’t Forget a Type in a Declaration
Wrong:
Location = GetActorLocation(); //What is Location? The compiler doesn't know
Fix:
FVector Location = GetActorLocation(); //Now the type is clear
Summary: How to Fix C2275 in UE5
Cause | Fix |
---|---|
Using a type without a variable | Add a variable name and initializer |
Forgetting the type in a declaration | Specify the type explicitly (FVector , int32 , etc.) |
Missing include for a custom type | Include the correct header file |
Typing a type alone | Don’t write just FVector; , use FVector VarName; |