shooter game example question(about API using)

Hi guys I am just a UE4 beginner and I am learning C++ module from the shooter game example, I saw the head file in ShooterEngine.h that defines as follow:

class SHOOTERGAME_API UShooterEngine : public UGameEngine

/* Hook up specific callbacks */
virtual void Init(IEngineLoop* InEngineLoop);


 *     All regular engine handling, plus update ShooterKing state appropriately.
virtual void HandleNetworkFailure(UWorld *World, UNetDriver *NetDriver, ENetworkFailure::Type FailureType, const FString& ErrorString) override;


In that class define I can not find where the SHOOTERGAME_API is been defined and I dont know what it is used for, can anyone help me with it? or can just give me some reference about that?

SHOOTERGAME_API is defined in the ShooterGameModule code, it’s just an export macro. Any class that needs to be accessed externally from the ShooterGame Module (in this case, the UShooterEngine), needs that tag.

That is a define that is important for the DLL that is created for your module. This is “should do” behavior if your code is going to be a DLL. The name of the macro is implementors choice for sure. In Unreals case it is always MODULENAME_API.

Defines do not need to exist at code time and can get defined at compile time.

so… its a export macro but is it defined in the game project? or which file it is defined?

It’s defined at the module level as @Rumbleball said. If I want “MyGameEditor” module to access classes in “MyGame”, then I need to mark those classes with the export tag (e.g. MYGAME_API )