Announcement

Collapse
No announcement yet.

GConfig can not be recognized/ can not be defined?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    GConfig can not be recognized/ can not be defined?

    hi guys, I try to modify the ini file in my game project access using BlueprintLibrary class, but my VS can not find out GConfig as it invoked. my code is on the below:

    Code:
    //MyBlueprintFunctionLibrary.h
    
    #include "Kismet/BlueprintFunctionLibrary.h"
    #include "MyBlueprintFunctionLibrary.generated.h"
    
    /**
    *
    */
    UCLASS()
    class CPP_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
    {
    GENERATED_BODY()
    
    public:
    UFUNCTION(BlueprintCallable, Category = "FileConfig")
    static float ReadConfig();
    
    UFUNCTION(BlueprintCallable, Category = "FileConfig")
    static int ReadConfigInt(FString key, int iDefaultValue);
    
    };




    Code:
    //MyBlueprintFunctionLibrary.cpp
    
    
    
    float UMyBlueprintFunctionLibrary::ReadConfig() {
    
    float ValueReceived = 0.f;
    
    return ValueReceived;
    }
    
    int UMyBlueprintFunctionLibrary::ReadConfigInt(FString key, int iDefaultValue) {
    {
    if (!GConfig) return 0;
    
    int fValueReceived = 0;
    FString VictorySection = "DefaultSetting";
    
    if (GConfig->GetInt(
    *VictorySection,
    *key,
    fValueReceived,
    GGameIni
    ))
    {
    return fValueReceived;
    }
    
    }
    the compile error message is on "if (GConfig->GetInt())" , says pointer to incomplete class type is not allowed, can anyone tell me if I missed any head file or how to invoke GConfig?
    Last edited by TheJamsh; 02-19-2019, 11:56 AM.

    #2
    It's complaining because it doesn't know what GConfig is. That's what "pointer to incomplete class type is not allowed" means.

    GConfig seems to be declared in CoreGlobals.h - so you need to include that header in your CPP file.

    Comment


      #3
      Originally posted by TheJamsh View Post
      It's complaining because it doesn't know what GConfig is. That's what "pointer to incomplete class type is not allowed" means.

      GConfig seems to be declared in CoreGlobals.h - so you need to include that header in your CPP file.
      I include the CoreGlobals.h file this time, but it still says:

      Error (active) E0393 pointer to incomplete class type is not allowed

      is that because my compiler didnt figure out the head file? my Cpp code is:



      #include "MyBlueprintFunctionLibrary.h"

      #include "CoreGlobals.h"

      float UMyBlueprintFunctionLibrary::ReadConfig() {

      float ValueReceived = 0.f;

      return ValueReceived;
      }

      int UMyBlueprintFunctionLibrary::ReadConfigInt(FString key, int iDefaultValue) {
      {
      if (!GConfig) return 0;

      int fValueReceived = 0;
      FString VictorySection = "DefaultSetting";

      if (GConfig->GetInt(
      *VictorySection,
      *key,
      fValueReceived,
      GGameIni
      ))
      {
      return fValueReceived;
      }

      }

      Comment

      Working...
      X