AStaticMeshActor undeclared identifier

I’m getting a compile error in 4.7 that did not occur in any previous version.

AStaticMeshActor is being treated like an undefined identifier.

This is my header file:

#pragma once

#include "GameFramework/GameMode.h"
#include "ArchGameMode.generated.h"

UCLASS(minimalapi)
class AArchGameMode : public AGameMode
{
	GENERATED_BODY()

public:
AStaticMeshActor* SMActor;
TArray<AStaticMeshActor*> SMActors;

};

And I’m getting compile errors:

"syntax error : missing ‘;’ before ‘*’

missing type specifier - int assumed. Note C++ does not support default-int

‘AStaticMeshActor’ : undeclared identifier

syntax error: ‘>’

And so forth.

Do I need to explicitly include the AStaticMeshActor class now in 4.7? What is going on here? It feels like I’m missing something obvious but after checking, double checking, coming back 8 hours later and checking again, I still can’t figure out what it is.

As I ruminate on this, a thought:
Previously I always compiled from source. Now I’m just making my project straight out of the installer in 4.7. Is that the difference? But if so, why is not having trouble identifying other classes? Hmm…

maybe you just need to include the StaticMeshActor class…
Runtime/Engine/Classes/Engine/StaticMeshActor.h

I checked and the class IS in the solution. If I try to include it:

#include "StaticMeshActor.h"

I get a compile error "Cannot open include file: ‘StaticMeshActor.h’: No such file or directory.

I’m quite baffled.

That gets the same compile error.
Cannot open include file: ‘Components/StaticMeshActor.h’: No such file or directory

try Components/StaticMeshActor.h. Solution is inrelevent, UBT never use VS project file, you actully dont need those files to compile.

I upgraded to 7.2.3 and completely reinstalled in the process. I started a new project from scratch and the only thing I added was this one line, declaring an AStaticMeshActor variable in the gamemode.h file. The problem persists. Any ideas?

It just occurred to me to work around this by making a new child class of StaticMeshActor that serves as a proxy. I am able to reference that and declare it as a variable. I’m not going to call that an answer because it doesn’t deal with the actual problem, but at least it lets me continue working.

Try #include "Engine/StaticMeshActor.h"

1 Like

Wrekk answers the question in a comment above.

#include “Engine/StaticMeshActor.h”

And for future reference, as I discovered after he made this comment, this is the include that is added automatically when you make a child class of StaticMeshActor. So, if encountering this problem again in the future with another class the first thing I would try if you’re not sure what to include is making a child of the class you need and checking to see what the default #include is for that child.