VS Code: Code shows errors in IDE, yet builds are successful

I have issues, reminiscent of IDE errors from Visual Studio, were the IDE is putting out false errors, which lead to no or limited intellisense. I have rebuilt the project a few times, re-generated the project, tried to run with Editor open, and closed.

The project does build with no errors, so these are IDE issues, but I do’t know if they are caused by unreal setup or VS Code itself.

Also note: This is in a plugin, and it doesn’t seem to understand the class SIMPLESOCKETS_API part… there are still errors if I remove it, but it stops saying that SIMPLESOCKETS_API is a class.

Environment: Windows 10, Just clicked Update on VSCode (1.18.1?), 4.18 Unreal.

221376-h.png

in the header file, the : when hovered says ‘expected a “;”’

in the cpp file: On USocketComponent:: it says “name followed by ‘::’ must be a class or namespace name” also same error on Super:: and any variable error reads “identifier ‘variablename’ is undefined”

What does it say as “error” when you hover your mouse over the red underlined words?

It’s not an error but just an MSVC inaccuracy. These underlines usually disappear when MSVC finishes to build a program database.

so how long should it take to build a program database? its been a very long time and I still get these errors…

It is in most cases for me a missing include.
But in most cases I don’t want that.
The code is building, more includes mean longer build time.
So the IDE is not happy. So what? Who cares.

So what? Who cares.

Really? It’s kind of a big deal. This throws off all useful linting from vscode because it’s hung on this one error.

Here’s an example of why this could be a headache for someone. There’s a simple typo that would normally be caught by the linter, but now it isn’t.

Same problem here. New project, all I’ve done here is create an Actor C++ file. My environment is macOS 10.13.1, UE 4.18.

Same issue over here (Linux, UE 4.18.2) - Plonking "C_Cpp.intelliSenseEngine": "Tag Parser", in your VSCode config seems to help (In terms of better tag completion), but then you’re left with zero error checking :confused:

I have just continued working on my project while I hope this gets looked at eventually… I just have to build and wait for compile errors to show any typos, etc… also more research is required to remember the methods and properties that intellisense would simply remind of on a regular basis. Fairly annoying… I will try @CraftedCart’s option and see if it makes it any better tho.

include “Engine.h” !!!

in your .h file.

source:Unreal Engine 4 —— 常见Tips_谁允许你直视本大叔的?-CSDN博客

225003-

][1]

like this

I have added this, and, yes the errors go away, but now I need to know why this happens… before I can say this is the definitive answer.

i dont know more.
syntax error caused by “InputCoreTypes.h”

I fixed it by updating my c_cpp_properties.json. The “defines” field can take values in the form of “define=value”, so in my case I was working with a FPSGAME_API causing the issue and I made my defines:

            "defines": [
                "_DEBUG",
                "UNICODE",
                "FPSGAME_API="
            ],

You can probably do something similar with
“SIMPLESOCKETS_API=”

As already said, the problem is solved by fixing the file c_cpp_properties.json. I just copied the definitions from the Visual Studio 2017 project and it worked.

The code for c_cpp_properties.json file (works for UE 4.18 and Windows 10)
But you need to change the line: “ORIGINAL_FILE_NAME=‘UE4Editor-ProjectName.dll’”

"defines": [
                "IS_PROGRAM=0",
                "UE_EDITOR=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_COREUOBJECT=1",
                "USE_STATS_WITHOUT_ENGINE=0",
                "WITH_PLUGIN_SUPPORT=0",
                "WITH_PERFCOUNTERS=1",
                "USE_LOGGING_IN_SHIPPING=0",
                "WITH_LOGGING_TO_MEMORY=0",
                "USE_CACHE_FREED_OS_ALLOCS=1",
                "USE_CHECKS_IN_SHIPPING=0",
                "UE_BUILD_MINIMAL=0",
                "WITH_EDITOR=1",
                "WITH_SERVER_CODE=1",
                "WITH_CEF3=1",
                "WITH_XGE_CONTROLLER=1",
                "UBT_COMPILED_PLATFORM=Win64",
                "UBT_COMPILED_TARGET=Editor",
                "WIN32=1",
                "_WIN32_WINNT=0x0601",
                "WINVER=0x0601",
                "PLATFORM_WINDOWS=1",
                "DEPTH_32_BIT_CONVERSION=0",
                "NDEBUG=1",
                "UE_BUILD_DEVELOPMENT=1",
                "ORIGINAL_FILE_NAME='UE4Editor-ProjectName.dll'",
                "UE_IS_ENGINE_MODULE=0",
                "UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=0",
                "UE_PROJECT_NAME=NewTest",
                "DEPRECATED_FORGAME=DEPRECATED",
                "NEWTEST_API=",
                "UE_ENABLE_ICU=1",
                "WITH_VS_PERF_PROFILER=0",
                "WITH_DIRECTXMATH=0",
                "CORE_API=",
                "COREUOBJECT_API=",
                "WITH_PHYSX=1",
                "WITH_APEX=1",
                "WITH_APEX_CLOTHING=1",
                "WITH_CLOTH_COLLISION_DETECTION=1",
                "WITH_PHYSX_COOKING=1",
                "WITH_NVCLOTH=1",
                "WITH_RECAST=1",
                "ENGINE_API=",
                "APPLICATIONCORE_API=",
                "RHI_API=",
                "JSON_API=",
                "SLATE_DEFERRED_DESIRED_SIZE=0",
                "WITH_FREETYPE=1",
                "SLATECORE_API=",
                "INPUTCORE_API=",
                "SLATE_API=",
                "WITH_UNREALPNG=1",
                "WITH_UNREALJPEG=1",
                "WITH_UNREALEXR=1",
                "IMAGEWRAPPER_API=",
                "MESSAGINGCOMMON_API=",
                "MESSAGING_API=",
                "RENDERCORE_API=",
                "SHADERCORE_API=",
                "UTILITYSHADERS_API=",
                "ASSETREGISTRY_API=",
                "ENGINEMESSAGES_API=",
                "ENGINESETTINGS_API=",
                "SYNTHBENCHMARK_API=",
                "RENDERER_API=",
                "GAMEPLAYTAGS_API=",
                "WITH_GAMEPLAY_DEBUGGER=1",
                "AIMODULE_API=",
                "GAMEPLAYTASKS_API=",
                "DATABASESUPPORT_API=",
                "PACKETHANDLER_API=",
                "RELIABILITYHANDLERCOMPONENT_API=",
                "HARDWARESURVEY_API=",
                "UNREALED_API=",
                "BSPMODE_API=",
                "DIRECTORYWATCHER_API=",
                "DOCUMENTATION_API=",
                "LOAD_PLUGINS_FOR_TARGET_PLATFORMS=1",
                "PROJECTS_API=",
                "SANDBOXFILE_API=",
                "EDITORSTYLE_API=",
                "SOURCE_CONTROL_WITH_SLATE=1",
                "SOURCECONTROL_API=",
                "UNREALEDMESSAGES_API=",
                "GAMEPLAYDEBUGGER_API=",
                "BLUEPRINTGRAPH_API=",
                "HTTP_PACKAGE=1",
                "HTTP_API=",
                "UNREALAUDIO_API=",
                "FUNCTIONALTESTING_API=",
                "AUTOMATIONCONTROLLER_API=",
                "LOCALIZATION_API=",
                "AUDIOEDITOR_API=",
                "LEVELEDITOR_API=",
                "SETTINGS_API=",
                "INTROTUTORIALS_API=",
                "HEADMOUNTEDDISPLAY_API=",
                "VREDITOR_API=",
                "LANDSCAPE_API=",
                "PROPERTYEDITOR_API=",
                "ACTORPICKERMODE_API=",
                "SCENEDEPTHPICKERMODE_API=",
                "DETAILCUSTOMIZATIONS_API=",
                "CLASSVIEWER_API=",
                "GRAPHEDITOR_API=",
                "CONTENTBROWSER_API=",
                "ENABLE_HTTP_FOR_NFS=1",
                "NETWORKFILESYSTEM_API=",
                "SOCKETS_PACKAGE=1",
                "SOCKETS_API=",
                "UMG_API=",
                "MOVIESCENE_API=",
                "MOVIESCENETRACKS_API=",
                "WITH_OGGVORBIS=1",
                "XAUDIO2_API=",
                "AUDIOMIXERXAUDIO2_API=",
                "COLLECTIONMANAGER_API=",
                "ADDCONTENTDIALOG_API=",
                "USE_EMBREE=1",
                "MESHUTILITIES_API=",
                "MESHMERGEUTILITIES_API=",
                "HIERARCHICALLODUTILITIES_API=",
                "MESHREDUCTIONINTERFACE_API=",
                "ASSETTOOLS_API=",
                "KISMETCOMPILER_API=",
                "KISMET_API=",
                "CLOTHINGSYSTEMRUNTIMEINTERFACE_API=",
                "NETWORKREPLAYSTREAMING_API=",
                "AUDIOMIXER_API="
            ]

This is the best I’ve seen so far. But yeah, still no error checking, so it’s not reason enough for me to switch :confused:

I mean, yeah including “Engine.h” in the code might solve this, but we really should not have to be doing this. There’s a reason UE4 stopped that practice.

While I agree that the c_cpp_properties.json file is likely the culprit, your solution did not work for me. I may have just copied something wrong, or my project may required different defines than yours, however.

Could you let us know where you found this list? I looked through the .vs files and my VS2017 project and couldn’t find any list of defines like this.

In Visual Studio 2017: Project > Properties > Nmake > Preprocessor Definition > Edit
(And check the Include Search Path > Edit)