Unrecognized type 'void' in function library

UE4 version: 4.20.

Using the FORCEINLINE in my function library causes the following compile error:

I do have multiple functions in my library but they have a reutnr type of FVector, bool, or float. This void function doesn’t seem to compile and I’m not sure why. Here’s the function definiton:



UFUNCTION()
static FORCEINLINE void SomeFunctionName(UBoxComponent* Collision, UStaticMeshComponent* MeshComponent)
{
    // Do something
}


I’m not sure what’s causing this compile error, and was hoping that some of you might be able to guide me towards a solution.

**NOTE: **changing the function to return bool instead of being a void function, does seem to resolve the issue, however I’m not interested in returning anything.

you can try remove
FORCEINLINE recompile again.

I think FORCEINLINE has to go before static for UHT to parsed it correctly.

@thinkthen It will compile if I remove the “FORCEINLINE”, but there’s a reason for it to be there.

@Zeblote Doesn’t seem to make any difference, still won’t compile and gives me the same compile error.

FORCEINLINE should be placed before the UFUNCTION declaration if you want it to compile. See a similar issue here: Unrecognized type 'void' in FORCEINLINE fucntion - Programming & Scripting - Unreal Engine Forums

But even if that works, I do not think UFUNCTIONs can be inlined to begin with. However, the body of a UFUNCTION should have no issue calling an inlined function. If someone can confirm that to be the case, then using FORCEINLINE with UFUNCTIONs might as well be redundant?

Thanks for your help guys, but I just removed FORCEINLINE and created the .cpp file. I just found a guide online explaining function libraries, and followed his steps, but I like to have the definiton split from the declaration anyways :slight_smile: