Use undeclared identifiers

Hi I’m new on Unreal Engine 4, I follow a tutorial for create a game, and I have this kind of error on this AActor * GetOwner (); and the error is “error: use of undeclared identifier ‘GetOwner’”.
I tried to include “Runtime/Engine/Classes/GameFramework/Actor.h” but it’s no use.
So if you know how you can fix this it’s will be great.

Thank you.

Hello!!

Try to incluse just this:

#include "GameFramework/Actor.h"

but i think this isnt your problem, what kind of class is this? i mean did you inherited from AActor?
Because this error: error: use of undeclared identifier ‘GetOwner’ means your class does not have GetOwner function.

Technically only Actors and Actorcomponents have owner :slight_smile: So if this is some kind of blueprintfunction library or native c++ class without inheriting it from Actor or Component, GetOwner would not work.

Can you show the full class header and cpp file?

Hello.

You’re getting that error because GetOwner is not a static nor global scope function. However, since your function is static, you’re pretty much trying to use GetOwner as if it would be a static or global scope function. You have to call that function on valid instance of ActorComponent.

If you can’t make that function non-static, then you’d have to provide a reference to ActorComponent via function parameters.

Cheers.

Here you can find my cpp file and my class header

Hi, I removed the “Static” in my fonction and it’s still not working I have the same issue

And now I can’t even open my project on unreal engine, because when I try to open it, unreal can’t rebuild my project

Now you’ve declared it as global scope (within your cpp file only) function instead of member of your UOpenDoor class.

Add this declaration to your header file:

void OpenDoor();

And modify your implementation to include UOpenDoor:: in front of your function same. So it’s

  void UOpenDoor::OpenDoor()

instead of:

  void OpenDoor()