seems your class are character based and i don’t sure why it’s miss some parts, when i did my class in 4.8.3 it’s
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"
UCLASS()
class LIGHTARRAY_API AMyCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AMyCharacter();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
};
#include "GameFramework/Character.h"
#include "MyActorComponent.h"
#include "MyCharacter.generated.h"
UCLASS()
class LIGHTARRAY_API AMyCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AMyCharacter();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
UMyActorComponent* MyActorComponent_ref;
};
MyActorComponent.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class LIGHTARRAY_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
// Called when the game starts
virtual void BeginPlay() override;
// Called every frame
virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
};
I mean that my character file is very long, and most of it is unrelated to the compiler error. UCombat and UPerception are classes I wrote, they are subclasses of UActorComponent proprietary to my system, not part of unreal’s API.
sry, but then i have no idea what cause problem in your implementation without looking into full version, as i told code i gave above builds without error, if you won’t share your code for some reason, then you can try one of these:
try recreate your classes without copying tons of lines, maybe just names, in this case you may find something different
or
try remove extra parts in your code step by step to reduce code down to raw template version and check when it builds without errors, from this point you can try find what’s wrong with last removed part
I think Bolt-Action Balrog is right. This is a linker error. If you by any chance come across:
// This gives errors
SomeClass Instance;
// And this doesnt give any error
class SomeClass Instance;
Then it means linker cant link your SomeClass because it can not find it. What you are achieving by adding class in front of it is forward declaration. So it still can not find but thinks you will create it at some point.
Check if you included the correct header for your class and be sure your class is properly created.
Yea sure, if I re-add the #include"MCharacter.h", I get this in the log, where MCharacter.h(97) is the line where I declare a variable of type UPerception*:
Info Compiling game modules for hot reload
Info Parsing headers for MonsterSchoolEditor
Info LogCompile:Error: Circular dependency detected for filename C:\Users\username\Documents\Unreal Projects\projectname\Source\projectname\MCharacter.h!
Info Reflection code generated for MonsterSchoolEditor
Info Performing 7 actions (4 in parallel)
Info Perception.cpp
Info MCharacter.cpp
Info HitframeNotifyState.cpp
Info projectname.generated.cpp
Error c:\users\username\documents\unreal projects\projectname\source\ projectname \MCharacter.h(97) : error C2143: syntax error : missing ';' before '*'
Error c:\users\ username \documents\unreal projects\ projectname \source\ projectname \MCharacter.h(97) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Info CharacterStateChangeNotify.cpp
Info TransitionZone.cpp
You’re both absolutely right, the line causing the problem was one of the includes:
#include "MCharacter.h"
MCharacter is my custom character class, I confirmed that it’s correctly spelled and that there’s no circular reference anywhere, is there any other obvious reason why this would break the linker?
Looks like a circular reference to me, especially if it works if you prefix the declaration with “class”.
If your MCharacter inherits from ACharacter, that means that MCharacter includes the character header (which includes Perception.h), while Perception.h also tries to include MCharacter.h.
To solve this, you need a forward declaration, which is precisely prefixing the declaration with class:
#include “MCharacter.h” mean this file must be in same folder as current where it wrote, isn’t here red underline on this include in VS? if no red underline, then it just strange
i saw it’s possible to choose public or private when creating class in UE4 and in VS project have 2 separate folders, i think if your MCharacter.h inside “private” folder for example and another .h where you try include it from “public” folder - then VS can’t just find where the hell file is and for some reason doesn’t rise correct error
if you were deleting files from VS solution, note that files maybe not deleted physicly on HDD and exist in window’s file explorer, in this case you may get strange situation when you have actually 2 files MCharacter.h inside “public” and “private” folder and if your file where you include it lay in wrong folder, tricky VS can find it on HDD and think all fine, while it’s totaly wrong and you want use really another one
just a remind - don’t forget mark question as answered with little gray circle button under any answer (not comment, but whole answer) when problem solved, so anyone else later can have same question and may find solution faster, if you find solution on your own, don’t forget write it too, really interesting who’s bad guy in this problem
If you don’t need the implementation of the class inside the header files then forward declarations rather than #includes will keep your compile times down.