[4.4] Android packaging fails in C++ where Windows packaging succeeds, ObjectIterator involved

Dear Friends at Epic,

A community member is reporting that an Android packaging attempt is failing where the same exact C++ code succeeds when packaged for windows!

#The Errors

Projects\MyProject\Plugins\VictoryPlugin\Source\VictoryBPLibrary\Private\VictoryBPFunctionLibrary.cpp(902,18) :  error: initialization of pointer of type 'AActor *' to null from a constant boolean expression [-Werror,-Wbool-conversion]
        if (!Itr) return false;
                         ^~~~~
C:\Users\Desktop\Documents\Unreal Projects\MyProject\Plugins\VictoryPlugin\Source\VictoryBPLibrary\Private\VictoryBPFunctionLibrary.cpp(908,23) :  error: initialization of pointer of type 'AActor *' to null from a constant boolean expression [-Werror,-Wbool-conversion]
        if (!TheWorld) return false;
                              ^~~~~
C:\Users\Desktop\Documents\Unreal Projects\MyProject\Plugins\VictoryPlugin\Source\VictoryBPLibrary\Private\VictoryBPFunctionLibrary.cpp(1014,18) :  error: initialization of pointer of type 'AActor *' to null from a constant boolean expression [-Werror,-Wbool-conversion]
        if (!Itr) return false;
                         ^~~~~
C:\Users\Desktop\Documents\Unreal Projects\MyProject\Plugins\VictoryPlugin\Source\VictoryBPLibrary\Private\VictoryBPFunctionLibrary.cpp(1020,23) :  error: initialization of pointer of type 'AActor *' to null from a constant boolean expression [-Werror,-Wbool-conversion]
        if (!TheWorld) return false;
                              ^~~~~

The code

In every case it is equality tests using the ObjectIterator in the following code that is not succeeding on Android build:

//Get a PC to GetWorld() from
	TObjectIterator<APlayerController> Itr;
	if (Itr == nullptr) return false;
	
	//~~~~~~~~~~~~
	
	//Get World
	UWorld* TheWorld = Itr->GetWorld();
	if (TheWorld == nullptr) return false;
	//~~~~~~~~~~~~~~~~~

I understand that I can use a hidden WorldContext to get around this for BP nodes, and I do that in other nodes (more recent ones)

#The Issue

But what is concerning to me is that the android build is failing on a line that doesn’t seem android specific and has more to do with the definitions of the ObjectIterator’s iterator!

Any ideas?

Rama

The error seems to be clearly explained by the compiler - the function is question perhaps returns AActor * or compatible pointer, but you are instead returning boolean values. Visual Studio compiler is more lax, but it should have caught that too.

#Thank You RCL!

Oh wow, oops!

I never noticed that (very old BP code)

Here’s more of the code:

AActor* UVictoryBPFunctionLibrary::Traces__CharacterMeshTrace___ClosestSocket(
	const AActor * TraceOwner, 
	const FVector & TraceStart, 
	const FVector & TraceEnd, 
	FVector & OutImpactPoint, 
	FVector & OutImpactNormal, 
	FName & ClosestSocketName, 
	FVector & SocketLocation, 
	bool & IsValid
)
{
	IsValid = false;
	AActor * HitActor = NULL;
	//~~~~~~~~~~~~~~~~~~~~~~
	 
	//There may not be a trace owner so dont rely on it
	
	//Get a PC to GetWorld() from
	TObjectIterator<APlayerController> Itr;
	if (Itr == nullptr) return false;
	
	//~~~~~~~~~~~~
	
	//Get World
	UWorld* TheWorld = Itr->GetWorld();
	if (TheWorld == nullptr) return false;
	//~~~~~~~~~~~~~~~~~

#Thanks for The Help RCL!

Rama

You are welcome :slight_smile: