Multiple TOptional errors while building

Hi,

I have just created my first ue5.5 project as a Blueprint project, then added a C++ class via the editor. Now, when I try to build the project, I get LOTS of errors of “incomplete type” with TOptionals, such as:

incomplete type "TOptional<FString>" is not allowed
incomplete type "TSlateBaseNamedArgs<SGenericDialogWidget>" is not allowed

Those errors happen in the Engine files, like Dialogs.h, World.h, etc.

Any idea on how to fix that?

Thanks!

I’m having the exact same issue from a source build UE5.5 following the UE documentation for EOS. Not sure if its a bug and when it will be addressed.

Exactly the same thing happened to me.
Started with the FPS template with C++. Clicked “Add C++ class” in the editor. Then added a property to my actor class.
Now the solution won’t build with lots of "incomplete type “TOptional<…” errors.

TOptional as most templated variables (such as TMap etc) can’t be exposed to blueprints with the exception of TArray that seems to have extra logic to work with the reflection system.

If you leave it as pure c++ then it compiles no problem.

To compile make sure you also include

#include "Misc/Optional.h"

Unfortunately the Unreal macros limit the use of templates as they do not abide by normal c++ rules :frowning:

I’m getting this with a fresh C++ project in UE 5.1.1. Needless to say, a fix would be super

Fresh 5.51 project, getting the same errors. Anyone have any solutions? I reinstalled both unreal, and vs, a few times and still having the same error with fresh install.

Incomplete type errors are always an issue with missing includes somewhere. You’ll have to share the code that is generating the error. Follow 3dRaven’s advice and make sure you’ve included “Misc/Optional.h” prior to where the error is being generated.

Unfortunately this is a bad example because TMap and TSet are also templated types that are well supported by blueprint. Many Engine templates are also supported like TObjectPtr, TSoftClassPtr and TSoftObjectPtr.

Also as of 5.4 there is limited support for TOptional within reflection as well. You can make properties with it and do details panel work, but working with them in graphs or a function parameters is still unsupported.

Yet Maps and Sets most likely have some extra magic behind the scenes that help the reflection system handle them.

Until TOptional gets full support behind the scenes, it’s use will be for the most part limited to C++.
Haven’t checked 5.5 yet but the support may have been extended.

It’s a shame that Epic has to do work-rounds that hamper normal c++ paradigms like templates and namespaces.

Agreed, it’s unfortunate that they sort of half-■■■■■ it.
5.5 does not have any additional support for TOptional blueprint-wise.

Namespace are definitely weird and should have been supported. Templates make more sense to me as it can really be a struggle binding templates to any sort of scripting paradigm. Even Epic’s containers have to convert back and forth with a non-templated version that it bitwise compatible with the template (in the case of the containers).

1 Like

I’ve been getting the same issue with a fresh project also in 5.5.1. Just been following: Unreal Engine CPP Quick Start | Unreal Engine 5.5 Documentation | Epic Developer Community as this is my first time using Unreal. I haven’t added anything else, but the suggested code.

You will have to share your actual errors/code. There have been a couple of different problems in this thread. Usually it’s a missing include.

Sorry in my case the errors are:


My code is copied directly from the link I provided. (just the two file at the bottom of the page have been added) :slight_smile: So would I just add

#include "Misc/Optional.h"

to the FloatingActor.h file?

No, you shouldn’t be getting build errors from Engine files like that. Share your actual build output, not the Errors panel.

Ah I have solved my own issue. (facepalm) Live code has been enabled which prevented me building from the IDE. It was the last issue of a few in a row stopping me from compiling so presumed it was still an issue with VS code setup.
Thanks for the help regardless!!

4 Likes

Thanks! Turning off live code immediately solved my issue with build errors! New to unreal so most of its tools/features I don’t fully understand.

Thank You it also helped me to solve this problem thankyou very much