Skip to content

Instantly share code, notes, and snippets.

@boocs
Last active September 24, 2023 00:49
Show Gist options
  • Star 67 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save boocs/31e6c2e54815b7ba6246ee20315acf96 to your computer and use it in GitHub Desktop.
Save boocs/31e6c2e54815b7ba6246ee20315acf96 to your computer and use it in GitHub Desktop.
Removing red squiggles (Intellisense errors) for Unreal Engine

Removing red squiggles (Intellisense errors) for Unreal Engine

This guide should remove all Intellisense errors from your project. I've recently finished a Udemy series and had no problems fixing any Intellisense errors with this guide.

I've tested this in both Visual Studio 2019 and VSCode (Latest Microsoft C++ plugin). They both work. (Windows 10)

Some other compilers, with their version of Intellisense, may still be helped by some of this info.

Note: VSCode was used with Build Tools for Visual Studio 2019

Table of Contents:

Upgrade

If you just created a new project

Everyday coding errors

Intellisense reset

Lots of errors you can't seem to fix

Slow/Weird acting Intellisense

  • Coming Soon™

UE4 source code errors

GetLifetimeReplicatedProps errors

VSCode and UE v4.25.X Defines bug (updated Dec 4th, 2020)

VSCode and UE v4.26.0

VSCode Extension (4.25, 4.26.1+)

  • Step 11 VSCode Intellisense Fix Extension

How to fix red squiggles:

Step 0.

Try using the latest Visual Studio 2019 or VSCode Microsoft C++ Plugin.

Also update your compiler regularly. They might have Intellisense improvements.

As of March 12, 2021, Visual Studio 2019 and VS Build Tools 2019 are at v16.9.1


Step 1.

You've just created a new project.

You might have Intellisense errors right away.

Don't worry about those errors just yet.

  1. Create your first public C++ class.

    • Press the Public button, during class creation, so it's highlighted.
    • Your public class will be created in newly created directories named Public and Private.
  2. Close UE4

  3. Build your project successfully (Important)

    • Creates a new Intermediate/Build directory needed for *.generated.h #includes
  4. Close all files in your code editor and close the editor

  5. Go to your projects folder

  6. Right click on your Unreal Engine Project File

  7. Choose Generate Visual Studio Project Files

  8. This will add new Include Directories in your project's Intellisense includes list.

    • Adds a Intermediate/Build directory containing *.generated.h & *.gen.cpp files
    • Adds Public and Private directories
  9. Open up your code editor and rebuild the project.

  10. Wait for Intellisense's first long initialization (Should only happen once)

    • Visual Studio
      • Takes about ~5 minutes
      • Click Icon lower left VS to see info
    • VSCode
      • Can take as much at ~30 minutes
      • This is do to unneeded files being included in current auto-generated config
      • More on this later
      • Fire icon is Default Intellisense
      • Cylinder icon is Tag Parser Intellisense (what takes so long)

Your code should be free of any Intellisense errors.

You don't have to wait to code if you don't want. You may see slowness/errors though until it's finished. Once the long Intellisense init is finished I'd close and reopen VS to refresh it.


Step 2.

Everyday build errors

You've changed header file outside class structure

This usually happens after I've used some forward declarations, outside the class, in a header file. But fake errors can happen just by adding a single blank line. These happen because UE4 makes use of the __LINE__ macro.

(Only do these next steps if you have fake errors. If you don't have errors just Build normally.)

(2a.): You had no errors prior but now do when messing with a header file.

(There are 3 sections. A Universal method. One for VSCode and another for Visual Studio 2019)

Universal (VSCode and VS2019)

  • Build your project successfully
    • This creates a file Intellisense needs
    • Do this as close to changing the header file as possible
  • If Building doesn't fix it then...
  • Close Visual Studio and reopen
  • If the header is still erred go to step 2b.
  • Note: If this is inconsistent try using the specific version, of step 2a., for your IDE
  • You might even like the specific versions better than this Universal way.

(VSCode)

(This seems to consistently work)

  • Close the ,fake error, header file in VSCode

  • Close any CPP files that include the ,fake error, header

  • Build the project successfully. (Must close the files before this happens)

    • Building the project creates a file intellisense needs.
  • Open the fake error file. It should be error free.

  • Note: (Don't use the shortcut keys to reopen last closed file(s). It can cause an Intellisense freeze.)

  • If error is still there try restarting VSCode.

  • If still erred go to step 2b.

(Visual Studio 2019)

(I've only tested this a few times. I don't know if it's consistent)

  • Build the project successfully.
  • This creates a file Intellisense needs.
  • The ,fake error, file will still have errors.
  • Inside the fake error file, quickly create a blank line and delete it.
  • This will retrigger Intellisense and remove the error.
  • If error is still there try restarting Visual Studio
  • If still erred go to step 2b.

(2b.): If there's still an error from step 2a.

  • Add an arbitrary blank line to the fake erred file so intellisense gets triggered again.
  • Wait 10-30 seconds for intellisense to finish (bottom fire icon)
  • Close the header and any cpp file that includes it
  • Build the project successfully
  • Close Visual Studio and then reopen it
  • Open file. Fake errors should be gone.
  • Change back file and do step A if desired.
  • If still errors. Repeating Step B a few times can, a lot of times, work.
  • After you fix the harder Intellisense errors, Step A should work again after.

If it still errors try step 4

If it still errors try step 5


Step 3.

Everyday Build Errors

There are outliers that can be easily solved by adding the right include files.

(3a.) When doing stuff like this:

GetWorld()->GetAuthGameMode()

This builds just fine but intellisense will error on GetWorld().

pointer to incomplete class type is not allowed

These can be fixed just by adding #includes of the appropriate type.

#include "Engine/World.h"

(3b.) Another error sometimes occurs when using a derived class in the place of a base class parameter.

argument of type "UAnimSequence *" is incompatible with parameter of type "UAnimSequenceBase *"

Just add the right #include

#include "Animation/AnimSequence.h"

Step 4.

Intellisense reset

VSCode:

Put this setting in either a user or project config file.
"C_Cpp.intelliSenseCacheSize": 0
I actually recommend keeping this setting.

There's currently a problem with header files deleting/writing data during creation. Default Intellisense cache files can be around 1 Gigabyte each in UE4. When you type one line in a header it deletes and writes this ~1 GB file every time.

(Using Build Tools for Visual Studio 2019. If using Visual Studio's(IDE) Intellisense Engine with VSCode it might act the same)

You can always delete this setting if you want to go back to default.

Visual Studio 2019 (Untested):

  • Close Visual Studio
  • Go to your project folder
  • Open your .vs folder
  • You may have to look up how to show hidden folders in your OS
  • Search for a ipch folder somewhere inside your .vs folder
  • Delete it

Step 5.

Big Reset

This step should be rare. Only do this as last resort.

There are 4 substeps A-D.

A: Close all files in Visual Studio


B: Generate Visual Studio Project Files

There is a way to do this inside the UE4 Editor but don't do it that way.

  • Close your IDE(Visual Studio/VSCode)
  • Close the UE4 editor.
  • Now go to your project folder and right click on your Unreal Engine Project File. Choose Generate Visual Studio Project Files. (Even though it's says Visual Studio it'll still work with VSCode as long as that's what's set in the UE4 Editor)

This way is a little annoying because it will reset some IDE(Visual Studio) settings/config files. If you've changed any project settings from the default, they will be gone. But..

This won't hurt any of your project files!

This is a good option if nothing else has worked.


C: Delete *.gen.cpp and *.generated.h files

(Important to do this step after Step B:)

The easy way:

  • Go to your project folder.
  • Open the Intermediate folder.
  • Delete the Build folder.

You can also just search for these files and delete them all. Be careful when doing so and make sure you're only searching in the Intermediate\Build folder.


D: Open your project and Build it.

If this still doesn't work:

  • Close any source code files you have open
  • Do Step 4 (Reset Intellisense)
  • Do Step 5 again

Step 6.

Intellisense Slowness/Weirdness

Coming soon™


Step 7.

UE4 Source Code Intellisense errors

This fix wont fix UE4 Source Code errors but you should be able to just hide them as long as you:

  • Close any UE4 Source code files.
  • Minimize the UE4 Folder in your Project folder view

Sometimes after you close a UE4 Source code file it'll still show with Intellisense errors. Try these:

  • Open the UE4 Source code file back up and reclose it.
  • Minimize the UE4 Folder in your Project folder view
  • Restart your IDE(Visual Studio)

If you have a bunch of UE4 Source code fake intellisense errors:

  • Go to Step 5

Step 8.

GetLifetimeReplicatedProps

Special functions, like GetLifetimeReplicatedProps, don't require a header signature. When you build your project, it's added to a special header file. Sometimes this will mess up Intellisense.

If you've already tried Step 3 then try these:

  • Make sure in your header file, that there is no mention of the function.
  • It can't even be mentioned in a comment.
  • Close all files in Visual Studio and then close Visual Studio.
  • Do Step C, of Step 5 (Delete .gen.cpp/.generated.h)
  • Open up Visual Studio and Build project.
  • If still errors do all of Step 5

Step 9.

VSCode and UE 4.25.x Defines bug (updated Jan 7th, 2021)

Try my new VSCode extension that auto fixes these bugs: https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305


VSCode only (but could apply to other IDEs):

There's currently a bug with these versions where Intellisense defines are missing. You can solve this by doing these steps.

New Way #1

  • Build your current project successfully (This bug doesn't affect the Build proccess)
  • Search your project directory for the file Definitions.YourProjectName.h (replace YourProjectName with your actual project name)
  • Copy the file path
  • Open YourProjectName.code-workspace.json file
  • Place this code under "settings":
    "C_Cpp.default.forcedInclude": [
         "Path to Definitions.YourProjectName.h"
    ]      

Here's what it could look like:

... 
 "settings": {
	"typescript.tsc.autoDetect": "off",
	"C_Cpp.default.forcedInclude": [
		"J:\\Users\\UserName\\Documents\\Unreal Projects\\MyProject\\Intermediate\\Build\\Win64\\UE4Editor\\Development\\MyProject\\Definitions.MyProject.h"
	]
...

Restart VSCode when finished

New way #2

A more permanent solution comes from eWomerOC here: (scroll to bottom) https://answers.unrealengine.com/questions/955271/view.html

I have not tested this so use at own risk!


Old way (Shouldn't be needed)

  • Build your current project successfully (This bug doesn't affect the Build proccess)

  • Search your project directory for the file Definitions.YourProjectName.h (replace YourProjectName with your actual project name)

  • Open the file and copy the contents to your clipboard

  • In your project's .vscode directory, open the c_cpp_properties.json file

  • Find the line "defines": []

  • Paste the clipboard contents inbetween []

  • Go to the Edit menu and select Replace

  • In the window that pops up make sure .* is highlighted (Use Regular Expressions)

  • On the top text line paste this:

    #define ([\w_()]*) ([\w".\-()_]*)
    
  • On the bottom text line paste this(including comma):

    "$1=$2",
    
  • Click the Replace All button

  • Remove any lines starting with #undef

  • Scroll down and find errors having to do with quotes inside quotes.

    • You'll need to escape the inside quotes.
    • Example: "UBT_MODULE_MANIFEST="UE4Editor.modules"",
    • Becomes: "UBT_MODULE_MANIFEST=\"UE4Editor.modules\"",
    • The other two defines on my system that need this are UBT_MODULE_MANIFEST_DEBUGGAME and UE_APP_NAME
    • Your system maybe different
  • Scroll all the way down to the end and remove last comma that's inside the defines array

  • Right click on the the open file and select Format Document if needed

  • Defines bug should be gone

Note: If you ever Generate Project Files you'll have to redo these steps. Don't use a backup copy since the file could update with the Generate Project Files command.


Step 10.

VSCode and UE 4.26.0

This version is no longer supported in this guide. My Extension also no longer supports 4.26.0 but does support 4.25 and 4.26.1+.

https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305


Step 11.

VSCode Intellisense Fix Extension (4.25, 4.26.1+)

Unreal Engine 4.26.1 fixes the major bug plaguing 4.26.0 It still has some bugs though.

Try my VSCode extension that auto fixes these bugs: https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305

@chriswingler
Copy link

Thank you for this! Finally got intellisense working in VSCode on 4.25.1 !!

@boocs
Copy link
Author

boocs commented Jun 25, 2020

Thank you for this! Finally got intellisense working in VSCode on 4.25.1 !!

Awesome, glad it could help!

@TehMighty
Copy link

Finally..! You're amazing dude.

@TalNovatzky
Copy link

Thanks!

@Uraner5
Copy link

Uraner5 commented Dec 13, 2020

Good job! Thanks!

@waltz47
Copy link

waltz47 commented Dec 17, 2020

This fixed most errors on UE4.26 with VSCode.
Edit: Still have to Refresh Code and repeat Step 9 and 10 every time I create a new C++ class. Otherwise getting an error: " 'myfilename.h' not found in compilecommands_projectname.json. "

@boocs
Copy link
Author

boocs commented Dec 28, 2020

This fixed most errors on UE4.26 with VSCode.
Edit: Still have to Refresh Code and repeat Step 9 and 10 every time I create a new C++ class. Otherwise getting an error: " 'myfilename.h' not found in compilecommands_projectname.json. "

I'm creating a VSCode extension that will automatically fix every 4.26.0 bug that happens when you create a new class or regenerate project files. Almost done!

@PythonHacker-byte
Copy link

This fixed most errors on UE4.26 with VSCode.
Edit: Still have to Refresh Code and repeat Step 9 and 10 every time I create a new C++ class. Otherwise getting an error: " 'myfilename.h' not found in compilecommands_projectname.json. "

I'm creating a VSCode extension that will automatically fix every 4.26.0 bug that happens when you create a new class or regenerate project files. Almost done!

Sounds Great! When are you done with it? And what is it called?

@boocs
Copy link
Author

boocs commented Dec 29, 2020

Sounds Great! When are you done with it? And what is it called?

UE4 Intellisense Fixes, but I'll probably just release it as a sideload extension. I'm not sure about the rules on github on releasing the output folder with a typescript project. It's technically still code they're downloading.

I have 2 fixes down and working on 3rd. Shouldn't be too long.

@candoit-sk
Copy link

I try to fix red squiggles at UE4 4.26. But my VSCode still suffers. I try from step 9 to 12

@boocs
Copy link
Author

boocs commented Jan 2, 2021

I try to fix red squiggles at UE4 4.26. But my VSCode still suffers. I try from step 9 to 12

Step 10-12 is 4.26. Step 9 is 4.25.

You can reset your project and try again. Right click on your project's uproject file and choose Generate Visual Studio Project Files...

Try only Step 10 since it's the big one. Step 11-12 are minor bug fixes.

When trying step 10, make sure there are no spaces at the end of the find and replace strings.
When trying step 10, make sure you do 'Replace All' - only once. very important

@candoit-sk
Copy link

I did step 10. The red squiggles already disappear. But now, my class has "expected a ';' bug" message.
Capture

@boocs
Copy link
Author

boocs commented Jan 4, 2021

I did step 10. The red squiggles already disappear. But now, my class has "expected a ';' bug" message.

That's the bug that Step 10 should fix.

Try this:
Open YourProjectsName/.vscode/compileCommands_YourProjectsName.json

Search for the word command . Just search for the word, don't replace.
Find the first line that has 'command' and paste the line above it and the line with command.

For example, this is my first command and the line above it:

"file": "J:\\\\Users\\\\boocs\\\\Documents\\\\Unreal Projects\\\\MyProject\\\\Source\\\\MyProject\\\\MyProject.Build.cs",
"command": "\"\" -include \"J:\\Users\\boocs\\Documents\\Unreal 

Find the last 'command' and do the same as above. Mine looks like this:

"file": "J:\\\\Users\\\\boocs\\\\Documents\\\\Unreal Projects\\\\MyProject\\\\Source\\\\MyProject\\\\test\\\\test.md",
"command": "\"\" -include \"J:\\Users\\boocs\\Documents\\Unreal

Another thing, the file you posted the picture of: Try searching for it in compileCommands_YourProjectsName.json

Does it find it?
If it finds it, paste the "command": file line here.

@candoit-sk
Copy link

Yes, I found it and already fixed it. Thank you so much. It took me 5 days. <3 <3 <3 you so much.

@ntropy83
Copy link

ntropy83 commented Jan 5, 2021

I have applied the defines step from New Way 2 in Step 9 to UE 4.25 and that solved it for me. Intellisense is now working. I only have red squiggles on all of my include files left, all demanding for the "sys/sysctl.h". It doesnt break compile tho. If I search for that file I can find several within the Unreal Engine folder. In a sys folder in the clang compiler folders SDKs. I can find 4 sysctl.h all about the size of 2 kb and being in a sys folder. I have tried to include all one-by-one and that does resolve the red squiggles, yet breaks intellisense (same with all 4).

Anyone by chance came around that too?

@boocs
Copy link
Author

boocs commented Jan 5, 2021

Anyone by chance came around that too?

I might get rid of #2 if more people say it causes problems. I never tested it and also don't use 4.25 anymore.

I could get clang Intellisense to work on Windows and 4.25 just by Using #1 and changing the "C_Cpp.default.compilerPath" and "C_Cpp.default.intelliSenseMode"

VSCode does cheat and adds all Windows libraries automatically. Might be a manually process of adding libraries for a different OS.

UBT still uses cl to compile though.

@paulvanvulpen
Copy link

Thanks a ton for the fixes for UE4.26
On Mac I have another error though:

#include errors detected. Consider updating your compile_commands.json or includePath. Squiggles are disabled for this translation unit

cannot open source file "stdlib.h" (dependency of "/Users/Shared/Epic Games/UE_release/Engine/Intermediate/Build/Mac/UE4Editor/Development/Engine/SharedPCH.Engine.ShadowErrors.h")

When you browse to the files in question the list gets longer and longer. Basically it's not finding any of the standard C headers.

Do you perhaps have any idea why this happens?

@boocs
Copy link
Author

boocs commented Jan 8, 2021

cannot open source file "stdlib.h" (dependency of "/Users/Shared/Epic Games/UE_release/Engine/Intermediate/Build/Mac/UE4Editor/Development/Engine/SharedPCH.Engine.ShadowErrors.h")

Do you perhaps have any idea why this happens?

@paulvanvulpen
I got that error once on Windows when I tried to put SharedPCH.Engine.ShadowErrors.h in the general "C_Cpp.default.forcedInclude" setting.

Does it happen on a particular file or on all files? Did you just create a class recently?

You can try resetting your project and try my new Extension that automatically fixes 4.25/4.26 errors on startup. It's nice since you can reset your project without worry of having to redo any fixes. I realized I forgot to post about it here. I'll make another post announcing it.

@boocs
Copy link
Author

boocs commented Jan 8, 2021

I created a new VSCode extension that automatically fixes 4.25/4.26 Intellisense errors.
https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305

Make sure to remove any previous fixes and reset your project with Generate Visual Studio Project Files!

@ntropy83
Copy link

ntropy83 commented Jan 8, 2021

Anyone by chance came around that too?

I might get rid of #2 if more people say it causes problems. I never tested it and also don't use 4.25 anymore.

I could get clang Intellisense to work on Windows and 4.25 just by Using #1 and changing the "C_Cpp.default.compilerPath" and "C_Cpp.default.intelliSenseMode"

VSCode does cheat and adds all Windows libraries automatically. Might be a manually process of adding libraries for a different OS.

UBT still uses cl to compile though.

No dont remove #2 in step 9 it worked perfectly for me.
I tried changing the default compiler path to the shipped clang compiler of the UnrealEngine (was set to my system clang compiler). Did not work tho. The sys/sysctl.h intellisense complains about is in the usr folder of the shipped clang compiler. So the build does succeed its only intellisense complaining. I will just ignore the include error, since everything else is working perfect now and intellisense even is pretty fast.

Thanks for your help and the vs code extension. That is good work and deserves a Star. 👍

@paulvanvulpen
Copy link

paulvanvulpen commented Jan 8, 2021

cannot open source file "stdlib.h" (dependency of "/Users/Shared/Epic Games/UE_release/Engine/Intermediate/Build/Mac/UE4Editor/Development/Engine/SharedPCH.Engine.ShadowErrors.h")
Do you perhaps have any idea why this happens?

@paulvanvulpen
I got that error once on Windows when I tried to put SharedPCH.Engine.ShadowErrors.h in the general "C_Cpp.default.forcedInclude" setting.

Does it happen on a particular file or on all files? Did you just create a class recently?

You can try resetting your project and try my new Extension that automatically fixes 4.25/4.26 errors on startup. It's nice since you can reset your project without worry of having to redo any fixes. I realized I forgot to post about it here. I'll make another post announcing it.

Thanks for your reply boocs. I undid my changes, regenerated the project, installed your extensions and followed along. The changes are applied correctly so your plugin works great! So far so good.

It turns out that the other issue I'm having I could also reproduce on UE_4.24, so should be unrelated to the issues you're addressing.

@boocs
Copy link
Author

boocs commented Mar 13, 2021

Forgot to mention here that 1.0.0 of my VSCode extension was release. It supports 4.25 and 4.26.1+

https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305

@AssisrMatheus
Copy link

AssisrMatheus commented Mar 27, 2021

Whenever I create a C++ class inside a folder, it doesn't build correctly and we have to remove the folder name from the .cpp file's #include everytime to fix it and build correctly.

After doing that things build fine but then I get this error in my Output log from the C/C++ Configuration Warnings:

"ProjectilePlayerController.cpp" not found in "${workspaceFolder}\.vscode\compileCommands_Projectile.json". 'includePath' from c_cpp_properties.json in folder 'Projectile' will be used for this file instead.

In this case, my project is named "Projectile".

Then, every time I try to save a file, even a file with a single line, it takes ages to save, and this message shows up

image

Is there a way to "fix" that, so it builds correctly without having to do header thing and having those warnings?

Basically I can't create folders?

Then, there's the SLOOOOW intelisense, is that the way it works?

I love doing coding stuff but I'm considering switching to BP only because of those issues, they're driving me nuts.

Using unreal 4.26.1 and latest C++ extension for vs code. It's happening in a brand new project

@boocs
Copy link
Author

boocs commented Mar 27, 2021

@AssisrMatheus

Then, every time I try to save a file, even a file with a single line, it takes ages to save, and this message shows up

I have Format on Save turned off. Click on the Sprocket Icon in the lower left and go to Settings and search for Format on Save. It should be a check mark box you can uncheck. Still sounds weird though being so slow.

I also have auto save turned on in the File menu.

Is there a way to "fix" that, so it builds correctly without having to do header thing and having those warnings?

Usually when you add new classes the UE4 editor will auto add these files to your VSCode compile commands file (something it needs). I've heard on some systems it doesn't do this or if you add a file manually it won't do it. You can try resetting your project every time you add a class or folder to see if that works.

You can also try my Extension. I added support for missing files so you don't have to reset your project every time. I'm about to release a 2.0.0 version later today. You can try the 1.3.0 version now if you like but I'd definitely upgrade when I release the new version.

https://gist.github.com/boocs/f63a4878156295b6e854cac68672f305

@boocs
Copy link
Author

boocs commented Mar 28, 2021

@AssisrMatheus
I released the new version. I actually released it as v1.4.1.

@storyoftime66
Copy link

#include errors detected. Consider updating your compile_commands.json or includePath. Squiggles are disabled for this translation unit

cannot open source file "stdlib.h" (dependency of "/Users/Shared/Epic Games/UE_release/Engine/Intermediate/Build/Mac/UE4Editor/Development/Engine/SharedPCH.Engine.ShadowErrors.h")

Thanks for the vscode extension! Finally I got rid of the squiggles about this problem.

@MTN95
Copy link

MTN95 commented Oct 6, 2022

identifier :llmageWrapperModule is undefined
member function declared with override does not override a base class member .
more info here - https://d3kjluh73b9h9o.cloudfront.net/optimized/4X/f/8/c/f8c59fa4caaa1b122cae43f3d09e99fa9cd77e03_2_1035x582.png
help ? what step should i do ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment