Vscode-cpptools: Error squiggles with Unreal Engine 4.26 built from source on github and using latest patches

Created on 20 Oct 2020  路  33Comments  路  Source: microsoft/vscode-cpptools

I am using latest Unreal Engine 4.26 built from source on github and using latest patches... VS code intellisense is half broken.. It shows error squiggles on freshly created classes.. It doesnt understand the :: or \: and suggests to use ; instead in a freshly created c++ class..
Screenshot from 2020-10-18 22-33-10

And this is a fresh created class of type actor. Vs code is not able to understand variables and this UWorldPosition::UWorldPosition() is also marked as error as ;
As an officially supported IDE it always break with a certain extension or engine update :(

_Originally posted by @jatin-cbs in https://github.com/microsoft/vscode-cpptools/issues/5849#issuecomment-712420208_

Compile Commands Configuration Language Service bug fixed (release pending) quick fix

All 33 comments

@jatin-cbs

Could you provide your IntelliSense configuration settings by running the command C/C++: Log Diagnostics?

Could you also provide logs from enabling the language server? The logs will show which includePaths are parsed and sent to the IntelliSense engine. The first thing to ensure is that the required paths to any dependency libraries that the project needs is known to the IntelliSense engine.

There has been major bug for Mac users using Xcode or Visual Studio code. It still hasn't been resolved yet. I tried 4.26 previews and they still havent worked.

There has been major bug for Mac users using Xcode or Visual Studio code. It still hasn't been resolved yet. I tried 4.26 previews and they still havent worked.

@CreateLex is there a reference (post/link) to an issue using XCode? Is this issue due to some change in Unreal Engine?

There has been major bug for Mac users using Xcode or Visual Studio code. It still hasn't been resolved yet. I tried 4.26 previews and they still havent worked.

@CreateLex is there a reference (post/link) to an issue using XCode? Is this issue due to some change in Unreal Engine?

Yes. this issue is due to an unreal engine generated project error. still waiting for them to resolve this issue for Mac users. using Xcode and visual studio code. The cpp defines array is empty.

You tube Link.

https://www.youtube.com/watch?v=oGUnRNMyjsU&t=5s

@michelleangela

https://pastebin.com/FefTGxj3

here is the log you asked for.

@jatin-cbs

The logs from the language server look okay. Could you also send the IntelliSense configuration log by running C/C++: Log Diagnostics from the VS Code command palette?

The issue could be an incorrect IntelliSense configuration (like the file that has the class that is being used is not specified in the includePath property) _or_ there is an issue with Unreal engine.

Its probably not an issue with the engine as codelite is working and also qtcreator with clang....intellisense which has been entirely reworked in 4.26 release as per the unreal engine github commits, is also having this issue and he is on Fedora 32 so it is also not distro specific.. maybe UBT bug

https://pastebin.com/1yjwHPgC Here are the logs C/C++: Log Diagnostics @michelleangela

Check my guide for the #defines 4.26 bug. It might be the reason.
https://gist.github.com/boocs/31e6c2e54815b7ba6246ee20315acf96#Step-10

@boocs so this is a unreal project generation bug in the UBT rather than the vscode extension I think @boocs should this be closed ?

I'm not sure whose bug it is but the truth is it could be fixed rather easy with a UBT change. Should the first -include in a compile command file be blank? When researching the -include flag it did mention something special about the first -include command but I don't know.

I contacted Epic through a bug report about this twice. Once with a general problem and second time with the specific reason for the bug. I believe it was back in v. Preview 3 (we are now in v. Preview 5). They never added it to their bug tracker/issues though.

So:
This is a UE4 bug and Epic knows about this it and are going to fix it.
or
This isn't their bug and they're not going to patch something that isn't broke on their end.

@boocs probably they won't in 4.25 there is a patch which someone sent as a pull request to fix the defines but it never got accepted and I don't think they will update unreal 4.25 branch any more after 4.25.4. Is compile commands in 4.26 faster parsing than the 4.25 tho..

I will test it again and tell if this fixes it for me.. Thanks for the read me and you can also include https://gist.githubusercontent.com/ericwomer/142650e65473087073f30e5fb97fd6e8/raw/7955b060b4b8e7fcf2719630797a0de358092985/ue4_25-defines-fix.patch

This patch and apply it with... git apply ue4_25-defines-fix.patch
Inside the unreal engine directory..
You can include this in your readme for permanent 4.25 intellisense fix..

It's a separate issue so probably not. It may help in Source files but mine has already been decently fast. At least once Intellisense loads on switching to a source file. Fire symbol on the bottom info bar is for context aware Intellisense and cylinder symbol for tag parser Intellisense.

When typing inside a function of a source file the fire symbol shouldn't come on unless you're creating a new function. The tag parser symbol may come on but doesn't seem to affect performance. If the fire symbol comes on when typing inside a function of a source file, and Intellisense is slow, then there's something wrong.

Header files are a different beast and are always slow. Whenever you type in a header file it recalculates Intellisense which can take 20 seconds.
So type 1 line... 20 secs.
Type another.... 20 secs.

I am working on extension that fixes this though by switching to Tag Parser Intellisense when editing a header file. Source files will still have Context Aware Intellisense because you'll definitely miss it with source files if it's gone.

I will test it again and tell if this fixes it for me.. Thanks for the read me and you can also include https://gist.githubusercontent.com/ericwomer/142650e65473087073f30e5fb97fd6e8/raw/7955b060b4b8e7fcf2719630797a0de358092985/ue4_25-defines-fix.patch

This patch and apply it with... git apply ue4_25-defines-fix.patch
Inside the unreal engine directory..
You can include this in your readme for permanent 4.25 intellisense fix..

Does this need a full source code build to work?

@boocs This should probably work in the binary version as well.. you can apply it even if you downloaded Unreal Engine as zip or tar from github You just need git installed which probably you would have installed.. As the changes in this patch are done to
/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildModuleCPP.cs
These files are identical in the Binary version as well.. However I don't know how changes are applied in binary versions.. like make command..

@sean-mcmanus There is an issue now Unreal Engine 4.25 intellisense.. We fixed the defines and other stuff.. But now its showing error on include CoreMinimal.h

cannot open source file "sys/sysctl.h" (dependency of "CoreMinimal.h")
CoreMinimal.h needs sys/sysctl.h Is there something that needs to provide this can you confirm ?

Cannot open source file "sys/sysctl.h" means it is expecting to find this file somewhere.. Can someone investigate this..

Also if I can skip this sys/sysctl.h would be great.. Because of 1 wrong error in Unreal Include paths Vscode disables error checking in the whole cpp file

Oh I got the issue
/home/shuriken/Applications/UnrealEngine/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v16_clang-9.0.1-centos7/x86_64-unknown-linux-gnu/usr/include/

This is the path I added to includePaths and it solved the issue.. The main issue is Unreal Engine uses bundled clang and VS Code uses system clang. So including this solves it as sys/sysctl.h is a part of this directory :) Finally everything is working and intellisense is accurate and fast Thanks for everyone's help @sean-mcmanus @boocs

:+1:

@jatin-cbs If UnrealEngine ships with its own compiler, you can set the property "compilerPath" to that path as the C++ extension tries to get includes based off the compilerPath.

I believe I have the same problem just came to the wrong conclusion with my 4.26 bug guide even though the fix works for me.

The first command should be the compiler path and UE4 doesn't set it for my config (Windows) and I guess other configs as well. So I'll have to write another UE4 bug report, with the correct info, if someone hasn't done so already.

VSCode does now complain about this as well with a bunch of errors like so:
Attempting to get defaults from C++ compiler in compile_commands.json file: '-include'
Specified compiler was not found: -include

I don't remember it doing so before.

@boocs I don't think compiler path is the main issue as on Linux Unreal Engine uses clang for compilation and if clang is not found or not mentioned in the json file it defaults to usr/bin/clang
So not finding a compiler is not an issue on Linux if you have clang installed at a system level. So my compiler is working but still those same errors on 4.26.. your fix did worked tho.

I updated my fix. Has nothing to do with the -include flag. Just need some placeholder as first command. Let me know if this fix works as well.

"command": "
"command": "\"\"

https://gist.github.com/boocs/31e6c2e54815b7ba6246ee20315acf96#Step-10

I created a barebones, nothing to do with Unreal, test and it acts the same way.

So it could be Epics 4.26 bug - They should put a \"\" in place of a compiler path and let VSCode fallback to a compiler it finds.

It could also be VSCode's extension bug - They shouldn't throw away the first parsed command if it's determined to not be a compiler. But then you'd have to determine if it's a bad compiler path or an actual compiler flag.

It might be worth asking VSCode extension makers to fix this:
If the first command, in a compilation database, starts with a '-' then don't throw it away. Try to find a fallback compiler to use and use every compiler flag after "command": when found.

@boocs Its working.. yes an extension fix may be good @sean-mcmanus any suggestions regarding this ? We will have to replace all

"command": "
TO
"command": "\"\"
in compileCommands_YourProjectName.json

for 4.26 unreal release..
Can you make sure this is an extension bug or an engine upstream bug ?

Sure, I can create a bug -- but does someone have a simple repro?

I can put up the one I tested before. I'll need to look at it again to make sure everything is good and I'll post the link.

4.26.0 was just released (Out of Preview). No fixes.

The workaround I posted still works.

@sean-mcmanus A simple repro is

  1. Install Unreal Engine 4.26 using the Epic Games Launcher or built it from source on Windows or Linux respectively.
  2. Having VS Code with latest cpp extension.. Create a new cpp project, Generate the vscode project files

Expected result: After all the parsing and updating intellisense is done the vscode intellisense should understand classes :: and not show other false errors or incomplete intellisense

FIX : replacing all
"command": "
TO
"command": "\"\"
in compileCommands_YourProjectName.json file.

Here is the sample project created by @boocs which explains the error even further https://github.com/boocs/compilecommands

Okay, thanks for the repro info.

@michelleangela Were you planning to look at this? If not, you can re-assign it to me.

@sean-mcmanus
After my discussion with one of the teaching assistants at gamedev.tv they made a video explaining this error in Vscode. Please take a look at:

https://www.gamedev.tv/courses/learn-unreal-engine-c-developer-4-22-for-video-game-development/lectures/17467871

@boocs Can I have access of https://gist.github.com/boocs/31e6c2e54815b7ba6246ee20315acf96 to submit you some pull requests regarding Linux specific fixes for VScode ? Won't be more than a couple of lines.. Thanks.

Can I have access of https://gist.github.com/boocs/31e6c2e54815b7ba6246ee20315acf96 to submit you some pull requests regarding Linux specific fixes for VScode ? Won't be more than a couple of lines.. Thanks.

@jatin-cbs Sent invite

Was this page helpful?
0 / 5 - 0 ratings