What does COREUOBJECT_API & ENGINE_API macro?

I am new to C++. I see these macros in a lot of places in code, unfortunately either Xcode cannot find their definition or something else is going on. Where are these macros defined and what they do?

2 Likes

Ohhh I see, that is probably why Xcode cannot find definitions for these. They are probably skipped on the Mac platform altogether. Probably one should only include these when contributing to the engine code right? If I build custom classes for my game on a Mac platform where these are not defined than probably I can skip these?

Those macros are defined by the UBT, and are always in the form MODULENAME_API.

On Windows they handle setting up the DLL export/import declarations correctly; I’m not sure if they do anything on other platforms, as I’m not as familiar with how shared library exports work.

3 Likes

To be fair, Visual Studio can’t go to their definition either since they’re not defined in source code.

You mostly won’t need them for your own classes (unless you make a plugin/module for the editor or engine), however I have seen some questions on here related to inconsistent DLL linkage warnings, but clearly that is only an issue on Windows.

You should use the macro on every non-inlined function or class that you would like to be usable in another module. If you’re just making a game module, that will likely never be the case.

2 Likes

Where can I find the definition of those macros, I need to have a look into these?

1 Like

See SetupPublicCompileEnvironment() in Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModule.cs

1 Like

Is there any particular reason an engine plugin should not have it’s API exported? For example, the AnalyticsBlueprintLibrary? I’m trying to extend it but I need to export it’s API in order to do so.

Documentation: https://docs.unrealengine.com/latest/INT/Programming/Modules/API/index.html

Haha, I think I found it in Xcode->Project Build Settings->Preprocessor Macros, the value is empty~

If I would like to know the value of the Macro in Virtual Studio 2019,what can I do?