Error: This declaration has no storage class or type specifier - VoiceModule.h

Once i’ve included the following headers:

#include "CleanThirdPerson.h"
#include "RecordMicAudio.h"

#include "Runtime/Online/OnlineSubsystemUtils/Public/OnlineSubsystemUtils.h"
#include "Runtime/Online/Voice/Public/Voice.h"

I get the following error message:

Error: This declaration has no storage class or type specifier - VoiceModule.h
Error: C2086 'int VOICE_API': redefinition - VoiceModule.h

In VoiceModule.h it doesn’t seem to like any of these lines of code:

/** Logging related to general voice chat flow (muting/registration/etc) */
VOICE_API DECLARE_LOG_CATEGORY_EXTERN(LogVoice, Display, All);
/** Logging related to encoding of local voice packets */
VOICE_API DECLARE_LOG_CATEGORY_EXTERN(LogVoiceEncode, Display, All);
/** Logging related to decoding of remote voice packets */
VOICE_API DECLARE_LOG_CATEGORY_EXTERN(LogVoiceDecode, Display, All);

Did you add the Voice module to your module list in your build.cs files?

I haven’t… I’ve messed with my MyGame.Build.cs but how do I include the voice module?

// Uncomment if you are using online features
PrivateDependencyModuleNames.Add("OnlineSubsystem");
PrivateDependencyModuleNames.Add("OnlineSubsystemNull");

Done, out of curiosity how did you know it was a voice module? And that it needed to be included?

Copy+paste one of those lines, replace the bit in brackets with “Voice”

Error: C2086 ‘int VOICE_API’: redefinition - VoiceModule.h

The VOICE_API is the macro for exporting stuff from a module. The module name is the bit before _API. Your own project should have a similar macro, MYPROJECTNAME_API.