How do I fix these false Intellisense errors when using Unreal Engine 4.24.2 with VS2019 or VSCode?
Asked Answered
P

2

9

I'm following the Unreal Programming Quick Start guide

I've copied and pasted the code samples at the bottom of the guide. I've tried using both VS2019 and VSCode, and both give me the same errors:

UStaticMeshComponent *AFloatingActor::VisualMesh
pointer to incomplete class type is not allowed
static <error-type> UStaticMesh
name followed by '::' must be a class or namespace name

and a couple more...

When I compile in Unreal Engine, it compiles with 0 errors and works as intended.

Is there any way to fix these false errors and continue to use Intellisense / get code completion?

I really just want to be able to see the member funcs and definitions for components I'm using as I'm new to Unreal.

This is the code from the guide, as I have it in my source for this demo project:

FloatingActor.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FloatingActor.generated.h"

UCLASS()
class CPPTUTORIAL_API AFloatingActor : public AActor
{
    UPROPERTY(VisibleAnywhere)
        UStaticMeshComponent* VisualMesh;
    GENERATED_BODY()



public: 
    // Sets default values for this actor's properties
    AFloatingActor();

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FloatingActor")
        float FloatHeight = 20.0f;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "FloatingActor")
        float RotationSpeed = 20.0f;

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

};

FloatingActor.cpp


#include "FloatingActor.h"

// Sets default values
AFloatingActor::AFloatingActor()
{
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

    VisualMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    VisualMesh->SetupAttachment(RootComponent);


    static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube"));

    if (CubeVisualAsset.Succeeded())
    {
        VisualMesh->SetStaticMesh(CubeVisualAsset.Object);
        VisualMesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
    }
}

// Called when the game starts or when spawned
void AFloatingActor::BeginPlay()
{
    Super::BeginPlay();

}

// Called every frame
void AFloatingActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    FVector NewLocation = GetActorLocation();
    FRotator NewRotation = GetActorRotation();
    float RunningTime = GetGameTimeSinceCreation();
    float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
    NewLocation.Z += DeltaHeight * FloatHeight;       //Scale our height by a factor of 20
    float DeltaRotation = DeltaTime * RotationSpeed;    //Rotate by 20 degrees per second
    NewRotation.Yaw += DeltaRotation;
    SetActorLocationAndRotation(NewLocation, NewRotation);
}
Palma answered 22/2, 2020 at 18:52 Comment(6)
You could just leave intellisense on, use it for your purpose and ignore the false error messages.Augustineaugustinian
@JesperJuhl the little red squiggles for one are distracting, and for two will get conflated with actual errors. That's a pretty unhelpful suggestion.Palma
Epic encourages include what you use, which would probably fix the error. Your code still compiles because the mesh component is pulled in with actor.h.Abroms
Also, I would strongly advise against intellisense, it's prohibitively slow and will produce lots of false positives, even in engine code. The best alternative for visual studio isn't free unfortunately, but there may be some good code navigation tools available for vs code.Abroms
@Abroms thank you, including those fixed the issue. If you submit as an answer I'll gladly accept. The Microsoft C++ plugin for VS Code seems to work a lot faster than VS19's IntelliSense. Not sure if it's the same thing.Palma
Intellisense probably doesn't see the UStaticMeshComponent type declaration. You can try to explicitely forward declare that type: class UStaticMeshComponent; after #includes.Abroad
P
4

this error causes due to not defied in c_cpp_properties.json add this code in between "defines": [], of c_cpp_properties.json

ping me back if any problem occurs

if you get any headers issue like #pragma once follow this post : https://github.com/microsoft/vscode-cpptools/issues/3952

        "defines": [
            "IS_PROGRAM=0",
            "UE_EDITOR=1",
            "ENABLE_PGO_PROFILE=0",
            "USE_VORBIS_FOR_STREAMING=1",
            "USE_XMA2_FOR_STREAMING=1",
            "WITH_DEV_AUTOMATION_TESTS=1",
            "WITH_PERF_AUTOMATION_TESTS=1",
            "UNICODE",
            "_UNICODE",
            "__UNREAL__",
            "IS_MONOLITHIC=0",
            "WITH_ENGINE=1",
            "WITH_UNREAL_DEVELOPER_TOOLS=1",
            "WITH_APPLICATION_CORE=1",
            "WITH_COREUOBJECT=1",
            "USE_STATS_WITHOUT_ENGINE=0",
            "WITH_PLUGIN_SUPPORT=0",
            "WITH_ACCESSIBILITY=1",
            "WITH_PERFCOUNTERS=1",
            "USE_LOGGING_IN_SHIPPING=0",
            "WITH_LOGGING_TO_MEMORY=0",
            "USE_CACHE_FREED_OS_ALLOCS=1",
            "USE_CHECKS_IN_SHIPPING=0",
            "WITH_EDITOR=1",
            "WITH_SERVER_CODE=1",
            "WITH_CEF3=1",
            "WITH_LIVE_CODING=1",
            "WITH_XGE_CONTROLLER=1",
            "UBT_MODULE_MANIFEST=\"UE4Editor.modules\"",
            "UBT_MODULE_MANIFEST_DEBUGGAME=\"UE4Editor-Win64-DebugGame.modules\"",
            "UBT_COMPILED_PLATFORM=Win64",
            "UBT_COMPILED_TARGET=Editor",
            "UE_APP_NAME=\"UE4Editor\"",
            "NDIS_MINIPORT_MAJOR_VERSION=0",
            "WIN32=1",
            "_WIN32_WINNT=0x0601",
            "WINVER=0x0601",
            "PLATFORM_WINDOWS=1",
            "OVERRIDE_PLATFORM_HEADER_NAME=Windows",
            "NDEBUG=1",
            "UE_BUILD_DEVELOPMENT=1",
            "UE_IS_ENGINE_MODULE=0",
            "IMPLEMENT_ENCRYPTION_KEY_REGISTRATION()=",
            "IMPLEMENT_SIGNING_KEY_REGISTRATION()=",
            "DEPRECATED_FORGAME=DEPRECATED",
            "UE_DEPRECATED_FORGAME=UE_DEPRECATED",
            "INCLUDE_CHAOS=0",
            "WITH_PHYSX=1",
            "WITH_CHAOS=0",
            "WITH_CHAOS_CLOTHING=0",
            "WITH_CHAOS_NEEDS_TO_BE_FIXED=0",
            "PHYSICS_INTERFACE_PHYSX=1",
            "WITH_APEX=1",
            "WITH_APEX_CLOTHING=1",
            "WITH_CLOTH_COLLISION_DETECTION=1",
            "WITH_PHYSX_COOKING=1",
            "WITH_NVCLOTH=1",
            "WITH_CUSTOM_SQ_STRUCTURE=0",
            "WITH_IMMEDIATE_PHYSX=0",
            "GPUPARTICLE_LOCAL_VF_ONLY=0",
            "ENGINE_VTABLE=DLLIMPORT_VTABLE",
            "ENGINE_API=",
            "UE_ENABLE_ICU=1",
            "WITH_VS_PERF_PROFILER=0",
            "WITH_DIRECTXMATH=0",
            "WITH_MALLOC_STOMP=1",
            "CORE_VTABLE=DLLIMPORT_VTABLE",
            "CORE_API=",
            "TRACELOG_VTABLE=DLLIMPORT_VTABLE",
            "TRACELOG_API=",
            "COREUOBJECT_VTABLE=DLLIMPORT_VTABLE",
            "COREUOBJECT_API=",
            "NETCORE_VTABLE=DLLIMPORT_VTABLE",
            "NETCORE_API=",
            "APPLICATIONCORE_VTABLE=DLLIMPORT_VTABLE",
            "APPLICATIONCORE_API=",
            "RHI_VTABLE=DLLIMPORT_VTABLE",
            "RHI_API=",
            "JSON_VTABLE=DLLIMPORT_VTABLE",
            "JSON_API=",
            "WITH_FREETYPE=1",
            "SLATECORE_VTABLE=DLLIMPORT_VTABLE",
            "SLATECORE_API=",
            "INPUTCORE_VTABLE=DLLIMPORT_VTABLE",
            "INPUTCORE_API=",
            "SLATE_VTABLE=DLLIMPORT_VTABLE",
            "SLATE_API=",
            "WITH_UNREALPNG=1",
            "WITH_UNREALJPEG=1",
            "WITH_UNREALEXR=1",
            "IMAGEWRAPPER_VTABLE=DLLIMPORT_VTABLE",
            "IMAGEWRAPPER_API=",
            "MESSAGING_VTABLE=DLLIMPORT_VTABLE",
            "MESSAGING_API=",
            "MESSAGINGCOMMON_VTABLE=DLLIMPORT_VTABLE",
            "MESSAGINGCOMMON_API=",
            "RENDERCORE_VTABLE=DLLIMPORT_VTABLE",
            "RENDERCORE_API=",
            "SOCKETS_PACKAGE=1",
            "SOCKETS_VTABLE=DLLIMPORT_VTABLE",
            "SOCKETS_API=",
            "ASSETREGISTRY_VTABLE=DLLIMPORT_VTABLE",
            "ASSETREGISTRY_API=",
            "ENGINEMESSAGES_VTABLE=DLLIMPORT_VTABLE",
            "ENGINEMESSAGES_API=",
            "ENGINESETTINGS_VTABLE=DLLIMPORT_VTABLE",
            "ENGINESETTINGS_API=",
            "SYNTHBENCHMARK_VTABLE=DLLIMPORT_VTABLE",
            "SYNTHBENCHMARK_API=",
            "RENDERER_VTABLE=DLLIMPORT_VTABLE",
            "RENDERER_API=",
            "GAMEPLAYTAGS_VTABLE=DLLIMPORT_VTABLE",
            "GAMEPLAYTAGS_API=",
            "PACKETHANDLER_VTABLE=DLLIMPORT_VTABLE",
            "PACKETHANDLER_API=",
            "RELIABILITYHANDLERCOMPONENT_VTABLE=DLLIMPORT_VTABLE",
            "RELIABILITYHANDLERCOMPONENT_API=",
            "AUDIOPLATFORMCONFIGURATION_VTABLE=DLLIMPORT_VTABLE",
            "AUDIOPLATFORMCONFIGURATION_API=",
            "MESHDESCRIPTION_VTABLE=DLLIMPORT_VTABLE",
            "MESHDESCRIPTION_API=",
            "STATICMESHDESCRIPTION_VTABLE=DLLIMPORT_VTABLE",
            "STATICMESHDESCRIPTION_API=",
            "PAKFILE_VTABLE=DLLIMPORT_VTABLE",
            "PAKFILE_API=",
            "RSA_VTABLE=DLLIMPORT_VTABLE",
            "RSA_API=",
            "NETWORKREPLAYSTREAMING_VTABLE=DLLIMPORT_VTABLE",
            "NETWORKREPLAYSTREAMING_API=",
            "PHYSICSCORE_VTABLE=DLLIMPORT_VTABLE",
            "PHYSICSCORE_API=",
            "COMPILE_WITHOUT_UNREAL_SUPPORT=0",
            "CHAOS_MEMORY_TRACKING=0",
            "CHAOS_VTABLE=DLLIMPORT_VTABLE",
            "CHAOS_API=",
            "CHAOS_CHECKED=0",
            "CHAOSCORE_VTABLE=DLLIMPORT_VTABLE",
            "CHAOSCORE_API=",
            "INTEL_ISPC=1",
            "VORONOI_VTABLE=DLLIMPORT_VTABLE",
            "VORONOI_API=",
            "FIELDSYSTEMCORE_VTABLE=DLLIMPORT_VTABLE",
            "FIELDSYSTEMCORE_API=",
            "WITH_PHYSX_RELEASE=0",
            "UE_PHYSX_SUFFIX=PROFILE",
            "UE_APEX_SUFFIX=PROFILE",
            "APEX_UE4=1",
            "APEX_STATICALLY_LINKED=0",
            "WITH_APEX_LEGACY=1",
            "SIGNALPROCESSING_VTABLE=DLLIMPORT_VTABLE",
            "SIGNALPROCESSING_API=",
            "WITH_RECAST=1",
            "UNREALED_VTABLE=DLLIMPORT_VTABLE",
            "UNREALED_API=",
            "BSPMODE_VTABLE=DLLIMPORT_VTABLE",
            "BSPMODE_API=",
            "DIRECTORYWATCHER_VTABLE=DLLIMPORT_VTABLE",
            "DIRECTORYWATCHER_API=",
            "DOCUMENTATION_VTABLE=DLLIMPORT_VTABLE",
            "DOCUMENTATION_API=",
            "LOAD_PLUGINS_FOR_TARGET_PLATFORMS=1",
            "PROJECTS_VTABLE=DLLIMPORT_VTABLE",
            "PROJECTS_API=",
            "SANDBOXFILE_VTABLE=DLLIMPORT_VTABLE",
            "SANDBOXFILE_API=",
            "EDITORSTYLE_VTABLE=DLLIMPORT_VTABLE",
            "EDITORSTYLE_API=",
            "SOURCE_CONTROL_WITH_SLATE=1",
            "SOURCECONTROL_VTABLE=DLLIMPORT_VTABLE",
            "SOURCECONTROL_API=",
            "UNREALEDMESSAGES_VTABLE=DLLIMPORT_VTABLE",
            "UNREALEDMESSAGES_API=",
            "GAMEPLAYDEBUGGER_VTABLE=DLLIMPORT_VTABLE",
            "GAMEPLAYDEBUGGER_API=",
            "BLUEPRINTGRAPH_VTABLE=DLLIMPORT_VTABLE",
            "BLUEPRINTGRAPH_API=",
            "EDITORSUBSYSTEM_VTABLE=DLLIMPORT_VTABLE",
            "EDITORSUBSYSTEM_API=",
            "HTTP_PACKAGE=1",
            "CURL_ENABLE_DEBUG_CALLBACK=1",
            "CURL_ENABLE_NO_TIMEOUTS_OPTION=1",
            "HTTP_VTABLE=DLLIMPORT_VTABLE",
            "HTTP_API=",
            "UNREALAUDIO_VTABLE=DLLIMPORT_VTABLE",
            "UNREALAUDIO_API=",
            "FUNCTIONALTESTING_VTABLE=DLLIMPORT_VTABLE",
            "FUNCTIONALTESTING_API=",
            "AUTOMATIONCONTROLLER_VTABLE=DLLIMPORT_VTABLE",
            "AUTOMATIONCONTROLLER_API=",
            "LOCALIZATION_VTABLE=DLLIMPORT_VTABLE",
            "LOCALIZATION_API=",
            "WITH_SNDFILE_IO=1",
            "AUDIOEDITOR_VTABLE=DLLIMPORT_VTABLE",
            "AUDIOEDITOR_API=",
            "AUDIOMIXER_VTABLE=DLLIMPORT_VTABLE",
            "AUDIOMIXER_API=",
            "TARGETPLATFORM_VTABLE=DLLIMPORT_VTABLE",
            "TARGETPLATFORM_API=",
            "UELIBSAMPLERATE_VTABLE=DLLIMPORT_VTABLE",
            "UELIBSAMPLERATE_API=",
            "LEVELEDITOR_VTABLE=DLLIMPORT_VTABLE",
            "LEVELEDITOR_API=",
            "SETTINGS_VTABLE=DLLIMPORT_VTABLE",
            "SETTINGS_API=",
            "INTROTUTORIALS_VTABLE=DLLIMPORT_VTABLE",
            "INTROTUTORIALS_API=",
            "HEADMOUNTEDDISPLAY_VTABLE=DLLIMPORT_VTABLE",
            "HEADMOUNTEDDISPLAY_API=",
            "VREDITOR_VTABLE=DLLIMPORT_VTABLE",
            "VREDITOR_API=",
            "COMMONMENUEXTENSIONS_VTABLE=DLLIMPORT_VTABLE",
            "COMMONMENUEXTENSIONS_API=",
            "LANDSCAPE_VTABLE=DLLIMPORT_VTABLE",
            "LANDSCAPE_API=",
            "PROPERTYEDITOR_VTABLE=DLLIMPORT_VTABLE",
            "PROPERTYEDITOR_API=",
            "ACTORPICKERMODE_VTABLE=DLLIMPORT_VTABLE",
            "ACTORPICKERMODE_API=",
            "SCENEDEPTHPICKERMODE_VTABLE=DLLIMPORT_VTABLE",
            "SCENEDEPTHPICKERMODE_API=",
            "DETAILCUSTOMIZATIONS_VTABLE=DLLIMPORT_VTABLE",
            "DETAILCUSTOMIZATIONS_API=",
            "CLASSVIEWER_VTABLE=DLLIMPORT_VTABLE",
            "CLASSVIEWER_API=",
            "GRAPHEDITOR_VTABLE=DLLIMPORT_VTABLE",
            "GRAPHEDITOR_API=",
            "STRUCTVIEWER_VTABLE=DLLIMPORT_VTABLE",
            "STRUCTVIEWER_API=",
            "CONTENTBROWSER_VTABLE=DLLIMPORT_VTABLE",
            "CONTENTBROWSER_API=",
            "ENABLE_HTTP_FOR_NFS=1",
            "NETWORKFILESYSTEM_VTABLE=DLLIMPORT_VTABLE",
            "NETWORKFILESYSTEM_API=",
            "UMG_VTABLE=DLLIMPORT_VTABLE",
            "UMG_API=",
            "MOVIESCENE_VTABLE=DLLIMPORT_VTABLE",
            "MOVIESCENE_API=",
            "TIMEMANAGEMENT_VTABLE=DLLIMPORT_VTABLE",
            "TIMEMANAGEMENT_API=",
            "MOVIESCENETRACKS_VTABLE=DLLIMPORT_VTABLE",
            "MOVIESCENETRACKS_API=",
            "ANIMATIONCORE_VTABLE=DLLIMPORT_VTABLE",
            "ANIMATIONCORE_API=",
            "PROPERTYPATH_VTABLE=DLLIMPORT_VTABLE",
            "PROPERTYPATH_API=",
            "NAVIGATIONSYSTEM_VTABLE=DLLIMPORT_VTABLE",
            "NAVIGATIONSYSTEM_API=",
            "MESHDESCRIPTIONOPERATIONS_VTABLE=DLLIMPORT_VTABLE",
            "MESHDESCRIPTIONOPERATIONS_API=",
            "MESHBUILDER_VTABLE=DLLIMPORT_VTABLE",
            "MESHBUILDER_API=",
            "MATERIALSHADERQUALITYSETTINGS_VTABLE=DLLIMPORT_VTABLE",
            "MATERIALSHADERQUALITYSETTINGS_API=",
            "INTERACTIVETOOLSFRAMEWORK_VTABLE=DLLIMPORT_VTABLE",
            "INTERACTIVETOOLSFRAMEWORK_API=",
            "TOOLMENUSEDITOR_VTABLE=DLLIMPORT_VTABLE",
            "TOOLMENUSEDITOR_API=",
            "WITH_OGGVORBIS=1",
            "XAUDIO2_VTABLE=DLLIMPORT_VTABLE",
            "XAUDIO2_API=",
            "AUDIOMIXERXAUDIO2_VTABLE=DLLIMPORT_VTABLE",
            "AUDIOMIXERXAUDIO2_API=",
            "ASSETTAGSEDITOR_VTABLE=DLLIMPORT_VTABLE",
            "ASSETTAGSEDITOR_API=",
            "COLLECTIONMANAGER_VTABLE=DLLIMPORT_VTABLE",
            "COLLECTIONMANAGER_API=",
            "ADDCONTENTDIALOG_VTABLE=DLLIMPORT_VTABLE",
            "ADDCONTENTDIALOG_API=",
            "USE_EMBREE=1",
            "MESHUTILITIES_VTABLE=DLLIMPORT_VTABLE",
            "MESHUTILITIES_API=",
            "MESHMERGEUTILITIES_VTABLE=DLLIMPORT_VTABLE",
            "MESHMERGEUTILITIES_API=",
            "HIERARCHICALLODUTILITIES_VTABLE=DLLIMPORT_VTABLE",
            "HIERARCHICALLODUTILITIES_API=",
            "MESHREDUCTIONINTERFACE_VTABLE=DLLIMPORT_VTABLE",
            "MESHREDUCTIONINTERFACE_API=",
            "ASSETTOOLS_VTABLE=DLLIMPORT_VTABLE",
            "ASSETTOOLS_API=",
            "KISMETCOMPILER_VTABLE=DLLIMPORT_VTABLE",
            "KISMETCOMPILER_API=",
            "GAMEPLAYTASKS_VTABLE=DLLIMPORT_VTABLE",
            "GAMEPLAYTASKS_API=",
            "WITH_GAMEPLAY_DEBUGGER=1",
            "AIMODULE_VTABLE=DLLIMPORT_VTABLE",
            "AIMODULE_API=",
            "KISMET_VTABLE=DLLIMPORT_VTABLE",
            "KISMET_API=",
            "PHYSICSSQ_VTABLE=DLLIMPORT_VTABLE",
            "PHYSICSSQ_API=",
            "CHAOSSOLVERS_VTABLE=DLLIMPORT_VTABLE",
            "CHAOSSOLVERS_API=",
            "GEOMETRYCOLLECTIONCORE_VTABLE=DLLIMPORT_VTABLE",
            "GEOMETRYCOLLECTIONCORE_API=",
            "GEOMETRYCOLLECTIONSIMULATIONCORE_VTABLE=DLLIMPORT_VTABLE",
            "GEOMETRYCOLLECTIONSIMULATIONCORE_API=",
            "CLOTHINGSYSTEMRUNTIMEINTERFACE_VTABLE=DLLIMPORT_VTABLE",
            "CLOTHINGSYSTEMRUNTIMEINTERFACE_API=",
            "AUDIOMIXERCORE_VTABLE=DLLIMPORT_VTABLE",
            "AUDIOMIXERCORE_API=",
            "UE_PROJECT_NAME=FPSCpp",
            "FPSCPP_VTABLE=DLLEXPORT_VTABLE",
            "FPSCPP_API="
        ],
      
Phew answered 3/7, 2020 at 7:26 Comment(0)
N
0

I wrote a guide back then to remove those. https://gist.github.com/boocs/31e6c2e54815b7ba6246ee20315acf96

Those bugs are most likely missing headers in your cpp file. You usually just search google for the class name and the first link will probably be the docs for it. The docs will have the correct #include line you need to include it.

Also if you ever upgrade your Unreal Engine( 4.25 through 5.0) then I've create an VSCode extension to help fix config bugs. https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305

Nevernever answered 31/3, 2022 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.