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
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
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).
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!!