GAMEPLAYMESSAGERUNTIME_API in Lyra Project and the correct way to create SubSystems

Hey,

What is the use of GAMEPLAYMESSAGERUNTIME_API in the class definition of UGameplayMessageSubsystem?
It is a general question about this decorator in class/struct definitions in UE cpp code.

Also on same note, what is the correct way to create a subsystem? Is it to create the classes “by hand” in the IDE or is there a way to do it correctly from the Editor when adding a New C++ code?

Thank you1

The GAMEPLAYMESSAGERUNTIME_API macro causes the class to be exported by that module.

If you look in the Lyra Plugins/GameplayMessageRouter/Source directory, you will see two modules defined: GameplayMessageNodes and GameplayMessageRuntime.

The UE build system CAPITALIZES the module name GameplayMessageRuntime and appends _API. This pattern is repeated for all modules to define their export macro.

The LyraGame module, for example, has a LYRAGAME_API export macro. It is quite common to have to add this to Lyra C++ to export it so you can derive your own classes from it.

As for your second question, IMO you should not use the Unreal Editor to modify C++. If you’re working in C++, get a real IDE and have that IDE do the work for you. In your IDE, create a “New Unreal UObject”. It will create the appropriate .cpp and .h files and then you just modify it to be a SubSystem. Compile, THEN launch the editor, and your new subsystem exists.

1 Like

Thank you so much for the prompt response!
I am kinda afraid of the speed that I went to Rider website to look at the features. No harm in trying it for a month :slight_smile:

Regarding the _API. The reason I wanted to use the UE Editor is because it could fill in all these macros for me since I don’t know where to put them myself…