__FILE__ macro not working properly

Using the _FILE_ and _FUNCTION_ macros in unreal engine do not work properly.

UE_LOG(LogTemp, Log, TEXT("%s::%s::%d "), __FILE__, __FUNCTION__, __LINE__);

outputs:

㩃啜敳獲䙜慲歮䑜捯浵湥獴啜牮慥牐橯捥獴卜湡畧湩䥥汳湡層潓牵散卜湡畧湩䥥汳湡層牐癩瑡履浘䙬湵瑣潩䱮扩慲祲挮灰::塕汭畆据楴湯楌牢牡㩹䤺楮t::192

Which… uh… is not the file name nor function name, but it IS the correct line number, so _LINE_ works just fine.

Is there a way to fix this, or is that just the way it is?

1 Like

Answered my own question. For those wondering, this:

UE_LOG(LogTemp, Log, TEXT("%s::%s::%d "), *FString(__FILE__), *FString(__FUNCTION__), __LINE__);

Prints the correct thing. Just had to cast them to an FString first.

More information on this page.

Thank you.