A macro for convenient nullptr logging

Maybe someone will find it useful, here’s a macro for convenient logging of nullptrs using UE_LOG.

#define NULLPTR_LOG(ptr) UE_LOG(LogTemp, Error, TEXT("%s%s"), TEXT(#ptr), TEXT(" was nullptr"))

This way you just need to write something like NULLPTR_LOG(PressurePlate) to get a message bilde

if (PressurePlate)
{
    PressurePlate->GetOverlappingActors(OverlappingActors);
}
else
{
    NULLPTR_LOG(PressurePlate)
}
3 Likes

Cool Thanks!!

Privacy & Terms