I am porting an audio plugin project forward from 4.18 to 4.22. I ran up against this problem, after a while I found that this was generated by an #include "IAudioExtensionPlugin.h"
:
1>..\UnrealEngine\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\SoundEffectPreset.generated.h(88): error C2061: syntax error: identifier 'UClass'
1>..\UnrealEngine\Engine\Source\Runtime\Engine\Classes\Sound/SoundEffectPreset.h(15): error C2079: 'USoundEffectPreset' uses undefined class 'ENGINE_API'
1>..\UnrealEngine\Engine\Source\Runtime\Engine\Classes\Sound/SoundEffectPreset.h(15): error C2988: unrecognizable template declaration/definition
1>..\UnrealEngine\Engine\Source\Runtime\Engine\Classes\Sound/SoundEffectPreset.h(15): error C2143: syntax error: missing ';' before ':'
It seems that ENGINE_API
was not defined, but it is strange since the relevant section is:
#pragma once
#include "Core.h"
#include "CoreUObject.h"
#include "IAudioExtensionPlugin.h"
That is, Core.h
and CoreUObject.h
are included.
Nonetheless after some frustration I found that the following fixed the problem:
#pragma once
#include "Core.h"
#include "CoreUObject.h"
#ifndef ENGINE_API
#define ENGINE_API
#endif
#include "IAudioExtensionPlugin.h"
However this seems incorrect to me. What is the correct way to ensure ENGINE_API
is defined?
By the way part of the trouble has been to trace the #include
tree, since the errors show up in files that I do not include directly it takes a long time to figure out what is causing the problem. What is a good way to make it easier?
Secondly I had to pull in a lot of unrelated dependencies that were not necessary previously. I even had to add,
#define PHYSICS_INTERFACE_PHYSX 1
otherwise I got error,
Physics/PhysicsInterfaceDeclares.h(224): error C2338: A physics engine interface must be defined to build
The final list of new module dependencies I had to add was,
"AudioPlatformConfiguration",
"InputCore",
"RHI",
"RenderCore",
so I think PhysX came from RenderCore but none of these other than AudioPlatformConfiguration has much to do with my project. Nonetheless I get errors if I do not include them. For instance, InputCore seems to be required due to an,
#include "AudioDevice.h"
in my project. Any idea why such strange dependencies are suddenly required that were not required previously, and that appear to be unrelated to audio?
Thanks in advance.