UE 4.10 and C++: Additionnal help on module and header dependencies.


(Marc St-Jacques) #1

Hello.

Simply following Programming with the FMOD Studio C++ API page, I’m having problems including the right files for using the C++ API in UE4.

I am using the full FMOD tutorial project to which I add a C++ class of an AActor to test my code.

Also, PrivateDependencyModuleNames.AddRange(new string[] { "FMODStudio" }); is part of my Build.cs.

Here’s my code based on the example:

#include "FMOD_UE4_Tutorial.h"
#include "MyActor.h"
#include "FMODStudioModule.h"
#include "fmod_studio.hpp"
        
    void AMyActor::BeginPlay()
    {
    	Super::BeginPlay();
    
    	if (IFMODStudioModule::IsAvailable())
    	{
    		FMOD::Studio::System* StudioSystem = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext.Runtime);
    		if (StudioSystem)
    		{
    			// Use it here
    		}
    	}
    }

I needed to add FMODStudioModule.h so that IFMODStudioModule::IsAvailable() could be recognized but
EFMODSystemContext is not recognized though it is part of the same header file.

2>E:\Documents\Unreal Projects\FMOD_UE4_Tutorial\Source\FMOD_UE4_Tutorial\MyActor.cpp(24): error C2882: 'EFMODSystemContext': illegal use of namespace identifier in expression
2>E:\Documents\Unreal Projects\FMOD_UE4_Tutorial\Source\FMOD_UE4_Tutorial\MyActor.cpp(24): error C2228: left of '.Runtime' must have class/struct/union

So what’s correct procedure ?

Regards.


(Geoff Carlton) #2

You’re almost there, you just need to use the enum like this:

EFMODSystemContext::Runtime

(Marc St-Jacques) #3

Of course. It’s an Enum, silly me. :-).

Then someone should change the code on the tutorial page. It’s clearly marked as a dot (In fact, my code is a copy & paste).

Thanks a bunch, Geoff.


(Geoff Carlton) #4

Ah, thanks for letting me know. It will be fixed for the next version.