boocs / ue4-intellisense-fixes

Automatically fixes VSCode/Unreal Engine Intellisense Config bugs on startup
MIT License
162 stars 9 forks source link

#pragma once errors with simple first person UE5 project #22

Open max-cis opened 2 years ago

max-cis commented 2 years ago

Hi, I have used your extension to remove most of the problems but I am still getting a few. Unfortunately, I am required to use macos for this and I am not particularly familiar with various things.

My current setup is an i7 iMac so not on the M1 or anything. I was hoping I have set up the cppproperties for intelli sense to "macos-clang-x64". I left the compiler path to the default. Also, I am only using the option from your extension "UEIntellisenseFixes.enableFixes": true, "UEIntellisenseFixes.cppStandard": "c++17"`.

Any ideas on what I could do to fix this? I have attached a picture of the errors. Maybe it helps.

Thanks, M

Screenshot 2022-08-29 at 11 34 31
boocs commented 2 years ago

Some things to try:

Make sure you can build successfully first with the 'Editor' suffix config like so: image

This is a VSCode Build Task. TestFps is the project name and notice the 'Editor' suffix. Win64 might be Mac for you.

This will create some files needed for Intellisense if they're missing.

Now you'll need to reset your project which will add the new file paths to Intellisense configs. image

Right click on your *.uproject file and choose Generate Visual Studio Project Files (or something similiar). If you can't find it you can also do this by loading your project in to the UE5 Editor and choose this option from the Tools menu. It's called 'Refresh Visual Studio Code Project'. It's also possible inside VSCode. One of the debug configs is called Generate Project Files. You do need to install the Microsoft C# extension for it to work though.

Restart VSCode and see if it works.

Another thing to try, maybe the config you're using is bugged. image

You can click the Win32 which is the name of one of the intellisense configs. Yours will probably be named something different. When you click it you'll get a menu with two choices. Click the opposite config that's currently active. image

max-cis commented 2 years ago

Thanks for getting back so quickly. I managed to figure out the reason behind the problems.

I am not sure if it is because I didn't set up the compiler in your extension properly, but I needed to add the following two parameters to the c_cpp_properties.json file to ensure that all the errors went away.

  "includePath": ["${workspaceFolder}/**"],
  "compilerPath": "/usr/bin/clang",

I am not sure if you think it is worth adding this to the extension so it includes these two parameters when it corrects the file.

I don't know how to do it, but I think could be marked as a workaround in GitHub. May help other MacOS users.

boocs commented 2 years ago

I do have a compiler path setting in my extension but the includePath making it work is weird.

It would mean that it's not using the compile commands file for Intellisense and instead using the cpptools includePath setting.

This could also mean you're not using the 'smart' Intellisense and instead using the other intellisense called 'Tag Parser'.

Pretty strange. Are you sure you need the includePath setting for it to work?

leonfs commented 2 years ago

I'm running on a Mac M1 and I've been using the extension to fix a few IntelliSense problems (thanks by the way), but the whole discovery of files was really really slow. The loading of the symbols and suggestions would take ages. But, after reading the official docs of VSCode about C++ and seeing this issue thread, I decided to add the includePath property in the c_cpp_properties.json. I have to say it worked like a treat! Now the whole discovery of files and IntelliSense is super fast.

As a reference, my compiler path is: "compilerPath": "/usr/bin/clang++"

boocs commented 2 years ago

@leonfs I think that means you're using the Tag Parser Intellisense(which is fine). The latest UE4/UE5 use compile commands which override the includePath setting so includePath shouldn't be affecting anything.

The compile commands must have include errors which forces VSCode to fall back to instead use Tag Parser Intellisense.

leonfs commented 2 years ago

You might be right, actually. How do you find those include errors @boocs? For some reason, navigating with IntelliSense the UE code is super fast, but when I have to navigate my project's code, it is super slow.

There is clearly something not right.

boocs commented 2 years ago

Tag Parser Intellisense is super fast but not as smart as the default Intellisense which is fast with cpp files but slow with header files because of how it works(updates too often whenever you type).

You should be able to look at the cpptools(C_CPP) extension logs. The setting is called Logging Level. Set it to debug. I actually should just make a guide because it's really easy to check with the cpptools log. It'll take some time but let me do that.

leonfs commented 2 years ago

Also - In the logs of the C++ extension I see this:

[8/31/2022, 9:17:18 AM] For C source files, IntelliSenseMode was changed from "macos-clang-x64" to "macos-clang-arm64" based on compiler args and querying compilerPath: "/opt/homebrew/opt/llvm@12/bin/clang"
[8/31/2022, 9:17:18 AM] IntelliSenseMode was changed because it didn't match the detected compiler.  Consider setting "compilerPath" instead.  Set "compilerPath" to "" to disable detection of system includes and defines.
[8/31/2022, 9:17:18 AM] For C++ source files, IntelliSenseMode was changed from "macos-clang-x64" to "macos-clang-arm64" based on compiler args and querying compilerPath: "/opt/homebrew/opt/llvm@12/bin/clang"
[8/31/2022, 9:17:18 AM] IntelliSenseMode was changed because it didn't match the detected compiler.  Consider setting "compilerPath" instead.  Set "compilerPath" to "" to disable detection of system includes and defines.
[8/31/2022, 9:17:19 AM] For C++ source files, IntelliSenseMode was changed from "macos-clang-x64" to "macos-clang-arm64" based on compiler args and querying compilerPath: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
max-cis commented 2 years ago

@leonfs just to make you aware that I am running an older i7 iMac so my compiler settings will differ from yours. Make sure you are not confusing the settings. There is another thread regarding M1 settings.

@boocs I will have a look and report back. Sorry, got caught up in other things.

boocs commented 2 years ago

@leonfs I created a new issue for you called M1 Mac issues

max-cis commented 2 years ago

@boocs I started a brand new project and set the path in your extension. The settings are as follows:

    "UEIntellisenseFixes.compiler.path": "/usr/bin/clang",
    "UEIntellisenseFixes.compiler.strictPath": true,

There were no immediate errors, but it was stuck on Loading... for ages. I then got an error with the include path and then it found things. It did take very long in comparison to when the includepath was set before.

As far as I can tell, I am using the Default intelliSense. Is that not the proper one? The setting is set as follows:

"C_Cpp.autocomplete": "Default"

Any way to check if it is using the correct IntelliSense? Also, I haven't switched on your optimisation setting.

boocs commented 2 years ago

I don't know if you have have my latest extension version 3.2.0. But I changed the strict setting documentation to say only use it if the extension's path setting is the full compiler path.

Make sure to change it to the full xcode/clang or clang++ path.

Makes me think I should just detect if it's a full path and error if it's not(when using the strict setting).

If you decide to remove the strict setting you should do a Generate Project File on your project.

max-cis commented 2 years ago

I did read that in your extension. However, when you read the output it states that it is better to actually have the box ticked. When you say full path you mean absolute rather than relative, right?

boocs commented 2 years ago

Yep, I guess my extension change wouldn't have worked if /user/bin/clang is also an absolute path on some systems. Maybe I'll just detect it on Mac and make sure if you use the strict setting that xcode is in the path somewhere.

So basically on Mac if using the strict setting your path setting should look something like this: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang or clang++ since clang++ is what ue5 default compiles with on Mac.

boocs commented 2 years ago

You can also remove the strict setting and Generate Project Files to get back the full xcode clang path in your compile commands file.

After you Generate Project Files, you can also check my extension log to see what the compile commands compiler path is being set to by the Unreal Engine.

Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe" @"D:\EJ\Documents\Unreal Projects\CPPTest\.vscode\compileCommands_CPPTest\CPPTest.211.rsp"

For example, my project's extension log above it says it's using "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe"

boocs commented 2 years ago

Once you figure out the full path that Unreal chooses you can just copy and paste that into the path setting and reenable the strict setting. Actually since they're going to be the same anything I guess you don't need to use the strict setting if you don't want lol.

I'm thinking that maybe the strict setting was a bad idea and just reading the compile commands compiler setting and auto pasting it into the path setting would be better. That way it's up to you to install the correct clang and up to Unreal to detect and use the correct clang.

boocs commented 2 years ago

Here's how I'll fix this.

boocs commented 2 years ago

I released 3.3.0 with the path fixes. You can remove the strict setting and reset your project(Generate Project Files) to fix it.

The path setting will now be auto set based on what compiler Unreal chooses.

boocs commented 2 years ago

I've released my guide on how to check for VSCode config bugs. This is just a partial Include Errors release. Note: This will get reorganized and changed.

https://github.com/boocs/Unreal-VSCode-diy-config-check-github

max-cis commented 2 years ago

Ok, so I downloaded your latest version. Removed the strict flag and refreshed the project twice from Unreal 5. Restarted VSCode, got the extension to fix things and then I got errors with the includePath. See image below:

Screenshot 2022-09-01 at 15 17 11

I checked c_cpp_properties.json and it is set up as follows:

 {
            "name": "Test3Editor Editor Mac Development (Test3)",
            "intelliSenseMode": "clang-x64",
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "compileCommands": "/Users/lmnicosia/CIS/Projects/UE5/Test3/.vscode/compileCommands_Test3.json",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
 }

I tried adding "includePath": ["${workspaceFolder}/**"] to c_cpp_properties.json but that didn't fix anything. I set the strict flag and that made the error on Test3.h go away but the other two include errors stayed.

The current config in settings.json is:

  "UEIntellisenseFixes.enableFixes": true,
    "UEIntellisenseFixes.cppStandard": "c++17",
    "C_Cpp.default.intelliSenseMode": "macos-clang-x64",
    "workbench.editor.untitled.hint": "hidden",
    "UEIntellisenseFixes.compiler.path": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++",
    "C_Cpp.loggingLevel": "Debug",
    "UEIntellisenseFixes.compiler.strictPath": true,

Any ideas?

max-cis commented 2 years ago

Ok, so it appears that I managed to find a stable configuration.

I removed the strict flag and left the compilerPath in your extension blank and restarted VSCode. I checked and it was auto-completed with: "UEIntellisenseFixes.compiler.path": "/usr/bin/clang", So far no errors. The output of your extension is as follows:

Extension "UE Intellisense Fixes" 3.3.0 is now active!

Found Unreal Engine v5.0.3

Fixing compiler path in c_cpp_properties.json.
Auto updating extension's compiler setting to /usr/bin/clang
End fix c_cpp_properties compiler path.

Fixing compiler paths in compile commands.
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "/usr/bin/clang" @/Users/XXXXXX/CIS/Projects/UE5/Test3/.vscode/compileCommands_Test3/Test3.206.rsp
Compile Command Object wasn't modifed. Will not write file.

I have no idea why it doesn't like "UEIntellisenseFixes.compiler.path": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++".

Any ideas what's happening?

boocs commented 2 years ago

Seems like the project reset isn't working properly. It still has the /usr/bin/clang from the previous time.

Would it be possible to create a new project and see what compiler Unreal chooses for the compile commands (by checking extension log)?

(remember to leave the strict setting unchecked)

I'm also going to update my guide today for different ways to reset your project. Maybe one won't be broken. It'll be funny if it turns out your reset isn't broken and Unreal chooses usr/bin/clang for the compiler.

max-cis commented 2 years ago

I’ll quickly create a project and report back. Let’s see what’s happening!

On 1 Sep 2022, at 17:14, boocs @.***> wrote:

Seems like the project reset isn't working properly. It still has the /usr/bin/clang from the previous time.

Would it be possible to create a new project and see what compiler Unreal chooses for the compile commands (by checking extension log)?

(remember to level strict setting unchecked)

I'm also going to update my guide today for different ways to reset your project. Maybe one won't be broken. It'll be funny if it turns out your reset isn't broken and Unreal chooses usr/bin/clang for the compiler.

— Reply to this email directly, view it on GitHub https://github.com/boocs/ue4-intellisense-fixes/issues/22#issuecomment-1234496754, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALL3UBUXDYUXAEWGRDDIKWLV4DI5HANCNFSM575IWEFA. You are receiving this because you authored the thread.

max-cis commented 2 years ago

Ok, so I created a new project and let it do its thing. It seems that Unreal is using /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++. However, that gives a lot of errors! See extension output below and screenshot.

Searching for *.uproject file...
Searching with fast-glob found nothing. (Sometimes isn't bug)
*.uproject file was found!

Extension "UE Intellisense Fixes" 3.3.0 is now active!

Found Unreal Engine v5.0.3

Fixing compiler path in c_cpp_properties.json.
End fix c_cpp_properties compiler path.

Fixing compiler paths in compile commands.
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" @/Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_MyProject2/MyProject2.204.rsp
File write: /Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_MyProject2.json
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" @/Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_Default/MyProject2.204.rsp
File write: /Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_Default.json
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" @'/Users/Shared/Epic Games/UE_5.0/.vscode/compileCommands_MyProject2/MyProject2.204.rsp'
File write: /Users/Shared/Epic Games/UE_5.0/.vscode/compileCommands_MyProject2.json
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" @'/Users/Shared/Epic Games/UE_5.0/.vscode/compileCommands_Default/MyProject2.204.rsp'
File write: /Users/Shared/Epic Games/UE_5.0/.vscode/compileCommands_Default.json
Done fixing compiler paths.

Fixing invalid paths in response files.
MyProject2.204: Fixed paths count(50), Unfixed paths count(0)
MyProject2.204: Fixed paths count(50), Unfixed paths count(0)
End fixing invalid paths in response files.

Fixing *.generated.h files!
Searching with fast-glob found nothing. (Sometimes isn't bug)
Correct *.generated.h files are found! Note: This extension doesn't test if all *.generated.h files have been created.
For Intellisense, you'll need to Build any newly created project files with the 'Editor' suffix config (e.g. MyProjectNameEditor (platform) Development Build).
All response files have the correct *.generated.h path!
End fixing *.generated.h

Fixing missing compile command files.
No missing file paths found. No fixes needed.
No missing file paths found. No fixes needed.
End fix missing compile commands.

Warning about Public/Private directory
Searching with fast-glob found nothing. (Sometimes isn't bug)
Searching with fast-glob found nothing. (Sometimes isn't bug)
You do not have this directory structure so no warning needed.
End warn Public/Private Directory

Attempting to fix UE workspace(Add empty tag parser).
UE's tag parser includes are set to empty array for performance.
The setting limitSymbolsToIncludedHeaders is already set to true.
End fix UE workspace(Add empty tag parser).

Attempting to fix wrong cppStandard.
Info : UE4 should be default c++14 (it can be c++17 with some special configuration)
Info : UE5 should be c++17
Current VSCode/cpptools cppStandard is:  (Can be blank)
Current c_cpp_properties.json's cppStandard is: c++17 (Overrides VSCode/cpptools if not undefined)
MAIN workspace c_cpp_properties.json's cppStandard is already set.
Current c_cpp_properties.json's cppStandard is: c++17 (Overrides VSCode/cpptools if not undefined)
MAIN workspace c_cpp_properties.json's cppStandard is already set.
Current VSCode/cpptools cppStandard is:  (Can be blank)
Current c_cpp_properties.json's cppStandard is: c++17 (Overrides VSCode/cpptools if not undefined)
UE workspace c_cpp_properties.json's cppStandard is already set.
Current c_cpp_properties.json's cppStandard is: c++17 (Overrides VSCode/cpptools if not undefined)
UE workspace c_cpp_properties.json's cppStandard is already set.
End fix wrong cppStandard.

Fixing launch.json.

Attempting to fix the json of launch.json...
There was nothing to fix!
End fix launch.json.

Start fix wrong intellisense mode
Cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Didn't need to set intellisenseMode.
End fix wrong intellisense mode.

Attempting to fix UE workspace optimization.
Optimization of UE is disabled.
End fix UE optimization.

Writing /Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/c_cpp_properties.json to file.

Writing /Users/Shared/Epic Games/UE_5.0/.vscode/c_cpp_properties.json to file.

*** Number of error messages: 0
*** Number of warning messages: 0
If you get any errors you can try restarting VSCode to check if they've been fixed.

Extension is done.
Screenshot 2022-09-01 at 17 23 31

I don't know why, but the only way to get it to not fail is to use usr/bin/clang. It makes no sense!

boocs commented 2 years ago

Temporarily you can go into the path setting of the extension. It should now have to full xcode/clang++ path there.

Remove the ++ from the path and enable strict.

Restart VSCode and see if the errors go away with the new project. Enabling strict copies the path setting to your compile commands file overwriting the compiler choice that Unreal chose.

boocs commented 2 years ago

I'm wondering if this is a version issue?

Unreal requires specific XCode version for developing. It's XCode 12.4 for Mac development on UE5. It's weird because I thought after the release of 5.0.2 it required XCode 13 but it says only IOS projects require that.

https://docs.unrealengine.com/5.0/en-US/hardware-and-software-specifications-for-unreal-engine/

Do you know what version you have?

I know diffferent clang or xcode versions can cause problems. On Windows I can't use clang 14 to compile because it has a new warning and Unreal treats warnings as errros. I had to use clang 13 to compile on Windows.

max-cis commented 2 years ago

So, I did that and the errors keep on coming back. However, going to definition (F12) works! I checked XCode and I have 13.4.1. I am planning on deploying to iOS so I had to upgrade to whatever the latest version was.

I wonder why usr/bin/clang works though.

boocs commented 2 years ago

When you Build your project you're building with with XCode/clang++ so it does work. Pretty strange that Intellisense can't use the same compiler path.

stdlib.h is a system include and there are a lot of issues people have with them and clang. It could be Unreal isn't including something it should be. It also could be VSCode is failing at polling for system includes. Actually I know they auto poll system includes on Windows but with Mac maybe they don't and use what is listed in the compile commands/rsp(response) files.

If you put it back to what works can you check for system includes using my guide? https://github.com/boocs/Unreal-VSCode-diy-config-check-github

Also feel free to bail and get back to creating Unreal projects lol

max-cis commented 2 years ago

I am happy to help, however, I will try it tomorrow.

While I have done lots of development experience in Windows, I am totally new to MacOS/iOS. Without your extension, I would have wasted a lot of time trying to figure all this out. Also, kind of keen on understanding how all of these tools are talking to each other!

boocs commented 2 years ago

I wonder why usr/bin/clang works though.

Do you have more than one version of clang installed? Maybe that version is being used with usr/bin/clang and is more compatible with Intellisense.

Unreal does use the C version of stdlib.h so maybe there's some clang or 'VSCode Intellisense' auto detection there which says you need to use clang and not clang++

max-cis commented 2 years ago

As far as I can tell I only have just the one.

XXXX@XX:~$ clang --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
XXXX@XX:~$ clang++ --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I could try to use the /usr/bin/clang++ and see how it goes...

boocs commented 2 years ago

In your new project does it have this like you specified above or did you add this yourself?: "macFrameworkPath": [ "/System/Library/Frameworks", "/Library/Frameworks" ],

Just wondering because Unreal shouldn't really be adding this line since they won't work with compile commands(unless I'm mistaken)

max-cis commented 2 years ago

I didn't add that, it just came out of unreal like that.

max-cis commented 2 years ago

I wonder if I need to set C_Cpp.default.includePath to make it work...

boocs commented 2 years ago

I didn't add that, it just came out of unreal like that.

Strange. Maybe it's for the Tag Parser or something specific that VSCode needs for Macs.

Something else to try:

I was reading about VSCode compilerPath setting and it says you can skip the compiler query by setting it to an empty string. This could rule out a VSCode query error.

Trouble is my extension won't allow you to set it to that without causing problems.

Something to try:

  1. Remove the strict setting
  2. Create a new project and let my extension run (new project with the full xcode/c++ path)
  3. Disable my extension for the new project.
  4. In your test project open .vscode/c_cpp_properties.json
  5. Change both compilerPath settings to an empty string
  6. Restart VSCode and see what happens
max-cis commented 2 years ago

Still broken! :( At this point, I am not sure if reverting back to /usr/bin/clang will make the errors go away!

boocs commented 2 years ago

I wonder if I need to set C_Cpp.default.includePath to make it work...

includePaths are ignored because of the use of compile commands/response files

You can check out all your project's include paths by opening the response file listed in my extension logs:

Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" @/Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_MyProject2/MyProject2.204.rsp

The new guide, I mentioned, will also show the detected includes with the use of the C++ extension logs.

boocs commented 2 years ago

Ah, never mind about that compilerPath being set to "". I tried it on Windows and my Intellisense failed as well.

I wonder how much a cheap mac is that could create UE5 projects? lol

max-cis commented 2 years ago

Cheap Macs! lol To be honest, not a fan. Just this project requires a Mac to deploy to iOS.

I noticed that your extension doesn't seem to respect the strict flag. I tried reverting back to /usr/bin/clang and it wrote it over with the long path. However, after overwriting it manually with /usr/bin/clang and resetting the database the errors went away. The C++ extension output mentioned lots of tag parsing though.

Anyway, I will try your guide tomorrow and see if I can extract more info. I'm off to have dinner! Ta

boocs commented 2 years ago

Yeah the tag parser can take 15+ minutes when it first parses your project's symbols. You have to wait for it to finish to use my guide.

There is another command for, the VSCode cpptool extension, logs but I like the real time logs better (I've had the two different logs disagree before)

boocs commented 2 years ago

I noticed that your extension doesn't seem to respect the strict flag.

That's just my lazy coding. When you enable the strict flag you have to restart VSCode for it to work ( I guess I should mention that somewhere).

boocs commented 2 years ago

I been thinking about that macFrameworkPath setting and thinking maybe this is the bug this entire time. I think for clang++ to work it needs the full absolute path to the system libraries found in the xcode path. Or maybe the relative paths just aren't working for the full Xcode clang++ path.

I found this on stackoverflow:

"macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],

Does your Xcode have a similar path like that?

So I would try:

Does it work now?

Also can you search "/Applications/Xcode.app/Contents/Developer/Platforms" for stdlib.h to see where it is located? Or maybe just search your whole computer to see the different locations it's at.

max-cis commented 2 years ago

Ok, gave it a try. Still same errors:

Full output of the C++ debug log here https://pastebin.com/67FeQPuC

The c_cpp_properties.json is as follows:

{
    "configurations": [
        {
            "name": "MyProject2Editor Editor Mac Development (MyProject2)",
            "intelliSenseMode": "clang-x64",
            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "compileCommands": "/Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_MyProject2.json",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
        },
        {
            "name": "Mac",
            "intelliSenseMode": "clang-x64",
            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "compileCommands": "/Users/XXXX/CIS/Projects/UE5/MyProject2/.vscode/compileCommands_Default.json",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
        }
    ],
    "version": 4
}

and settings.json as follows:

    "UEIntellisenseFixes.enableFixes": true,
    "UEIntellisenseFixes.cppStandard": "c++17",
    "C_Cpp.default.intelliSenseMode": "macos-clang-x64",
    "C_Cpp.loggingLevel": "Debug",
    "UEIntellisenseFixes.compiler.path": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++",

I also used find to search for stdlib.h locations and found several. They are mostly related to different SDKs (didn't know I had more than one) and for different platforms:

/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdlib.h
/System/Volumes/Data/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdlib.h
/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/DriverKit.platform/Developer/SDKs/DriverKit.sdk/System/DriverKit/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/DriverKit.platform/Developer/SDKs/DriverKit.sdk/System/DriverKit/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/stdlib.h
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h
/System/Volumes/Data/opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/base/vendor/tcl8.5.19/compat/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/DriverKit.platform/Developer/SDKs/DriverKit.sdk/System/DriverKit/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/DriverKit.platform/Developer/SDKs/DriverKit.sdk/System/DriverKit/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/v1/stdlib.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/stdlib.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h
/opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/base/vendor/tcl8.5.19/compat/stdlib.h

Also, I followed your guide. The flame is on.

I also tried adding to the macframeworks path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++` instead of the one you suggested as that contains stdlib.h but still gave same errors.

I am surprised that it is not finding it!

boocs commented 2 years ago

Thanks for the logs!

Would you be able to post a log file of the same project that's working? (using strict and /usr/bin/clang)

It would be interesting to compare the two logs.

max-cis commented 2 years ago

Sure, will do. I think that one defaults to the tag parser though.

Best,

Max Nicosia Director Cambridge Intelligent Systems UK Ltd.

@.***

Salisbury House Station Road Cambridge England CB1 2LA

On Fri, 2 Sept 2022 at 11:18, boocs @.***> wrote:

Thanks for the logs!

Would you be able to post a log file of the same project that's working? (using strict and /usr/bin/clang)

It would be interesting to compare the two logs.

— Reply to this email directly, view it on GitHub https://github.com/boocs/ue4-intellisense-fixes/issues/22#issuecomment-1235324885, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALL3UBQAMQQKEK3QB223GQ3V4HH6HANCNFSM575IWEFA . You are receiving this because you authored the thread.Message ID: @.***>

max-cis commented 2 years ago

Hey, can you message me your email. Apparently, the log is way longer when using /usr/bin/clang and it is beyond the limit for paste bin.

boocs commented 2 years ago

You can cut out all Unreal Paths if that makes it shorter. If it's working but only uses tag parser then that seems weird.

I was looking at Macs and Unreal Engine requirements. The only hard requirement is Using the latest Monterey OS. I saw that I can get a ~$200 late 2014 Mac Mini that can run that OS. I just need to be sure it will be able to create Unreal Projects in UE4/UE5. It doesn't even need to run the engine.

max-cis commented 2 years ago

Even though I removed all the Epic ones, it still was over pastebin's limit. So, I split it into two. I guess that could work. I don't know if you can install Monterey on such an old mac. You should check if they have a limit...

https://pastebin.com/JuBgKDYh

https://pastebin.com/CiNqDCBP

boocs commented 2 years ago

There is something weird happening. Both logs say your clang gets detected as version 11

When I use clang 13.0.1 on Windows this is what is shown in logs:

other: --clang_version=130001

Will have to research and look at the logs more.

max-cis commented 2 years ago

That's pretty weird! Using which and --version yields the following:

XXX@XXX:~$ which clang
/usr/bin/clang
XXX@XXX:~$ clang --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
XXX@XXX:~$