Cannot print value of type FPlayInEditorID

It seems to be a warning but it compiles anyway so I don’t know if this is a Rider false-positive or what when I compiled and tested it the ID showed as a bunch of Zeroes, but when I deleted the folders and regenerated the project files and compiled again it seemed to fix it.

Cannot print value of type FPlayInEditorID with format specifier %d that implies type int

Just trying to understand the message better because I tried looking that up in the C++ API and it wasn’t very helpful.

I chased it down in Source Code though and found it’s declaration

class FPlayInEditorID
	CORE_API FPlayInEditorID& operator= (int32 InOther);
	CORE_API operator int32() const;

So I’m assuming it is a false positive?

Rider suggested I use a static_cast

I did and the message went away and it still seems to compile.

Correct me if I’m wrong, I am still learning. I have never seen an operator that looks like a function but is it possible that your actually supposed to cast it to an int32?

Ok so after looking into this a little further the ‘operator int32() const;’ is an implicit conversion that should be handled automatically without the need for a cast unless the explicit keyword is added, unless my sources are wrong. (For clarification it allows the class to be converted to another data type and unless I’m mistaken doesn’t require a direct cast for that to happen)

With this being said I think it’s more of a warning from the compiler as it may not think it’s safe for whatever reason. I don’t think it’s anything to be concerned about though.

There is definitely no need to cast, especially to int32 since it is already an int32. See this tooltip from rider.

Doc link from Rider doesn’t provide information but this one does, admittedly not much:
Visual Studio Tips and Tricks in Unreal Engine | Unreal Engine 5.3 Documentation

Just so you know, when working with Unreal Engine you should use Cast<>() and not static_cast where possible. Unreal have their own version which is an inline function and as such, is probably more efficient… You may hit issues when dealing with actors as well if you try using static_cast.

There are a number of quirks like this in Unreal C++ over standard C++ but generally you don’t need to dive as deep into the language as you would writing C++ software for embedded systems, for example.

I hope this helps.

1 Like

Yeah that clears it up quite a bit. I was just confused by the return type it was showing in Rider. Thanks for the tip on Casting, I had a feeling Unreal had their own version but wasn’t sure of the syntax.

Again, thanks for the insight. That clears it up quite a bit for me.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms