Why do I get the error: '__GNUC__' and '__clang_major__' not defined as a preprocessor macro.

Hello everyone,

I am new to Unreal Engine 5.5 and Unreal in general and have been struggling with the following issue for a few hours.

I am trying to create blueprint functions in C++ to enhence the UnrealGDAL plugin. I have written the following code:

// FILE: GDALFunctionLibrary.h

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"

#include "GDALFunctionLibrary.generated.h"

UCLASS()
class MOONSIMULATOR_API UGDALFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintCallable, Category = "GDAL")
	static void GetLocation(FString name, double latitude, double longitude);
};
// FILE: GDALFunctionLibrary.cpp

#include "GDALFunctionLibrary.h"

#include "gdal.h"
#include "UnrealGDAL.h"
#include "GDALHeaders.h"

void UGDALFunctionLibrary::GetLocation(FString name, double latitude, double longitude)
{
	GDALAllRegister();

	FString path = FString::Printf(TEXT("C:/Users/Ordinateur/Desktop/DEMs/%s.tif"), *name);

	GDALDataset* dataset = (GDALDataset*)GDALOpen(TCHAR_TO_ANSI(*path), GA_ReadOnly);

	if (!dataset) {
		UE_LOG(LogTemp, Warning, TEXT("Incorrect path: %s"), *path);
		return;
	}

	double transform[6];
	if (dataset->GetGeoTransform(transform) != CE_None) {
		dataset->Close();
		UE_LOG(LogTemp, Warning, TEXT("Failed to get geotransform data of %s"), *name);
		return;
	}

	double originX = transform[0];
	double originY = transform[3];
	double pixelWidth = transform[1];
	double pixelHeight = transform[5];  // Usually negative

	int pixelX = static_cast<int>((longitude - originX) / pixelWidth);
	int pixelY = static_cast<int>((latitude - originY) / pixelHeight);

	const char* projection = dataset->GetProjectionRef();

	dataset->Close();
}

But here is the following errors that I get:

incomplete type "TOptional<FString>" is not allowed
incomplete type "TOptional<bool>" is not allowed
incomplete type "TOptional<FCppClassTypeInfo>" is not allowed
incomplete type "TOptional<EMouseCursor::Type>" is not allowed
incomplete type "TOptional<FRegexPattern>" is not allowed
incomplete type "TOptional<FString>" is not allowed
member function declared with 'override' does not override a base class member
member function declared with 'override' does not override a base class member
incomplete type "TOptional<FString>" is not allowed
incomplete type "TOr<TAndValue<<error-constant>, TIsPODType<TOptional<FString>>>, TIsArithmetic<TOptional<FString>>>" is not allowed
incomplete type "TOptional<FString>" is not allowed
incomplete type "TOptional<TCircularBuffer<TUniquePtr<FBitReader, TDefaultDelete<FBitReader>>>>" is not allowed
incomplete type "TOptional<FNetworkCongestionControl>" is not allowed
identifier "FTextureBuildSettings" is undefined
incomplete type "TOptional<bool>" is not allowed
incomplete type "TOptional<bool>" is not allowed
incomplete type "TOptional<FMaterialLayersFunctions::ID>" (aka "TOptional<FMaterialLayersFunctionsID>") is not allowed
incomplete type "TOptional<int32>" (aka "TOptional<signed int>") is not allowed
incomplete type "TOptional<FRHIBreadcrumbNode *>" is not allowed
incomplete type "TOptional<const FRHIDrawStatsCategory *>" is not allowed
incomplete type "TOptional<const FRHIDrawStatsCategory *>" is not allowed
incomplete type "TOptional<ENamedThreads::Type>" is not allowed
incomplete type "TOptional<int32>" (aka "TOptional<signed int>") is not allowed
incomplete type "TOptional<ETextureDimension>" is not allowed
incomplete type "TOptional<ETextureDimension>" is not allowed
incomplete type "TOptional<FSlateClippingState>" is not allowed
incomplete type "TOptional<int32>" (aka "TOptional<signed int>") is not allowed
incomplete type "TOptional<int32>" (aka "TOptional<signed int>") is not allowed
incomplete type "TOptional<EHorizontalAlignment>" is not allowed
incomplete type "TOptional<EVerticalAlignment>" is not allowed
incomplete type "TOptional<TSharedRef<SWidget, ESPMode::ThreadSafe>>" is not allowed
incomplete type "TOptional<TSharedRef<const SWidget, ESPMode::ThreadSafe>>" is not allowed
incomplete type "SlateAttributePrivate::TSlateAttributeBase<SWidget, TOptional<FSlateRenderTransform>, std::conditional<true, SlateAttributePrivate::FSlateAttributeNoInvalidationReason, TSlateAttributeInvalidationReason<EInvalidateWidgetReason::None>>::type, TSlateAttributeComparePredicate<TEqualTo<void>>, SlateAttributePrivate::ESlateAttributeType::Member>::ObjectType" (aka "TOptional<TTransform2<float>>") is not allowed
incomplete type "TOptional<FAcc
[details="Summary"]
This text will be hidden
[/details]
essibleWidgetData>" is not allowed
incomplete type "TOptional<FSizeParam>" is not allowed
incomplete type "TOptional<int32>" (aka "TOptional<signed int>") is not allowed
incomplete type "TOptional<float>" is not allowed
incomplete type "TOptional<FText>" is not allowed
incomplete type "TOptional<EPopupMethod>" is not allowed
incomplete type "TOptional<EPopupMethod>" is not allowed
incomplete type "TOptional<EPopupMethod>" is not allowed
incomplete type "TOptional<double>" is not allowed
'__GNUC__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
'__GNUC__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
'__GNUC__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
'__GNUC__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
'__clang_major__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
'__clang_major__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
The command "E:\UE_5.5\Engine\Build\BatchFiles\Build.bat MoonSimulatorEditor Win64 DebugGame -Project="C:\Users\Ordinateur\Desktop\Projects\Unreal Engine\MoonSimulator\MoonSimulator.uproject" -WaitMutex -FromMsBuild -architecture=x64" exited with code 6.

I really don’t understand what’s going on, especially since it worked a few hours ago. I created a file to create a new struct to handle more return information from my function and since then nothing is working. Not sure if this is the problem.

I tried to rebuild the project so I deleted the following folders: Saved, Binaries and Intermediate but when I remove the Binaries folder the project is unable to build.

Everyone on the internet says this will fix the problem but it is not working for me.

Also, when I remove GDALFunctionLibrary.cpp and GDALFunctionLibrary.h from my folder, everything works again.

If you have any ideas, I would love to read them.

Hey @StarkTech47

Can you give more information about GDAL?

You are using a third-party library for your plugin, right? It looks like the headers you are including (gdal.h) require some preprocessor definitions to compile. So the issue isn’t with the plugin itself but with the included header. Are you linking a precompiled binary for that library, or are you trying to compile the entire library along with your plugin?.

Can you show me your plugin .build.cs file?

Hello @BRGDemianLopez and thanks for the reply.

I am sorry for this very late response. I contacted the author of plugin and he fixed the issue. It was link to some dependencies and library that was not included.

Here is the link to the new version: GitHub - ssav7912/GDALforUE5: Provides access to the GDAL/OGR API inside the Unreal Engine

Thank you