Issue Declaring Log Category

I have recently switched to Unreal, and was going about declaring a log category; though running into some issues.

Prior to posting, I already looked through the forums, finding posts such as:

Though unlike the posts above, I believe I have correct syntax and usage from what I have seen (I could be completely wrong as I’m still adjusting to the work environment) though still running into this error:

CompilerResultsLog:  ...\Source\FarmQuestCPP\Private\FQAssetManager.cpp(22) : error C2653: 'FLogCategoryFarmQuestCPPLog': is not a class or namespace name
CompilerResultsLog:  ...\Source\FarmQuestCPP\Private\FQAssetManager.cpp(22) : error C2065: 'CompileTimeVerbosity': undeclared identifier
CompilerResultsLog:  ...\Source\FarmQuestCPP\Private\FQAssetManager.cpp(22) : error C2065: 'FarmQuestCPPLog': undeclared identifier
CompilerResultsLog:   ...\Source\FarmQuestCPP\Private\FQAssetManager.cpp(22) : error C2672: 'FMsg::Logf_Internal': no matching overloaded function found
CompilerResultsLog:   ...\Source\FarmQuestCPP\Private\FQAssetManager.cpp(22) : error C2780: 'void FMsg::Logf_Internal(const ANSICHAR *,int32,const FName &,ELogVerbosity::Type,const FmtType &,Types...)': expects 6 arguments - 4 provided
CompilerResultsLog:  ...\Epic Games\UE_4.21\Engine\Source\Runtime\Core\Public\Logging/LogMacros.h(55): note: see declaration of 'FMsg::Logf_Internal'

Here are the files in question:


#pragma once

#include "CoreMinimal.h"
#include "Engine.h"



#include "FarmQuestCPP.h"

IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, FarmQuestCPP, "FarmQuest" );

/** Logging definitions */

And finally where the error occurs:


 UE_LOG(FarmQuestCPPLog, Fatal, TEXT("Error Message!"));

Also I should note, FQAssetManager.h inherits FARMQUESTCPP_API as such:

class FARMQUESTCPP_API UFQAssetManager : public UAssetManager

If anyone has the time to check everything above to see where and if I messed up. I have been able to circumvent this issue temporarily using LogTemp, though I would like to implement my own categories for logging.

Thank you, and I hope someone is able to help out!

FARMQUESTCPP_API is not needed there, it’s macro that pastes “extern” if it’s needed (since on monolith build it not needed) and DECLARE_LOG_CATEGORY_EXTERN already does that job as you doing _EXTERN version. That macro is not needed overall if you only have single module and you dont plan to communicate with it from outside.

You also need to include header file where DECLARE_LOG_CATEGORY_EXTERN is if you gonna use log category as that macro creates nesesery classes for UE_LOG

Ahh, that makes sense, thank you for pointing that out! Still adjusting to CPP, as you can probably already tell; Java has corrupted my brain.

Though I will include the header file and test it out once more! Just setting up my work environment for CLion, so I will report back once get it running and am able to test it out!

Thank you for taking the time to look it over!

Update: Thank you for pointing out including the header. It somehow slipped my mind, though everything compiled fine after that!