Open max-cis opened 2 years ago
In your logs it also shows the clang version as 13.1.6 as well so I still think something is wrong with the mac system includes which is why VSCode detects it as version 11.
I was going to rent a cloud Mac to figure this out but if you want to keep going we can.
Here's what I want to try:
I want to see any mac paths that are included, if any, without the "macFrameworkPath" setting so we get a baseline.
Happy to keep the helping, but today I am fighting another battle and I will be away on Sunday. Will try on Monday :)
No problem, I decided to rent the mac anyway because I need to test M1 Macs as well.
Don't bother doing it. The framework setting is something else and has nothing to do with includes. VSCode auto includes system paths for Mac just like it does on Windows. So it could be VSCode just isn't including the path to stdlib.h.
Still on going but thought I'd give an update.
So this must be a Mac C++ extension bug?
I never even used my extension and just used /usr/bin/clang++ in the compile command file and it worked. Looking at the C++ extension logs shows it including a bunch of paths added from here:
Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/
Also usr/bin/clang works as well.
Even when it works it says clang_version=110000
So basically an easy fix for Unreal 5.0.3. I don't need to change anything on MacOS except the compiler path in the compile commands to /usr/bin/clang++
That's interesting. When I first set up the VSCode in MacOS and used the compiler path it didn't work at all. That's why I went searching and came across your extension.
So, does it work straight up if I set up the compiler path in the c_cpp extension to usr/bin/clang++
?
Yeah that's because the compiler in the compile commands file overrides the compilerPath setting in c_cpp_properties.
So I I think I'm going to change my extension and have 2 compiler paths. One for c_cpp_properties.json where I have it as an error if it's set. Having it blank will remove the compilerPath setting from c_cpp_properties.
One for compile commands file, compiler path, where I will default it to /usr/bin/clang++ for Macs. Or maybe I just won't auto set it and just explain in the instructions that they should use /usr/bin/clang++
I think it would be good if you have a setting that, if ticked, it sets it, otherwise it leaves it. I would suggest writing in the setting that if not ticked, the user is responsible to set it for Mac to /usr/bin/clang++. Makes it a lot easier when trying to do a quick deployment. In most cases, you just want to get it working ASAP rather than understanding how all the components interact with one another.
I just kept it simple. One path setting no strict setting. If path isn't set it gets pulled from compile command compiler path and set. Once set it will set both compile commands compiler and compilerPath setting if they are different.
I tested it on my cloud M1 Mac and it works as long as I have the path set to /usr/bin/clang++
Ok, cool! Have you created a new release?
Also, I got two questions you may know about. I cannot find any info atm.
1) When trying to build from VSCode the debug build, not the GameDebug I get the error:
ERROR: Targets cannot be built in the Debug configuration with this engine distribution.
Any idea why? GameDebug does build fine.
2) Is there any way to ensure that the Unreal Editor is not killed after you stop debugging from VSCode? As it takes a while to restart the Editor. If I have the Editor open, it just opens a copy for debugging. It doesn't attach to the running instance.
Thanks!
Yep 3.4.0 is released!
...trying to build from VSCode the debug build
That's normal since you're not using the full source build that option wont work.
the Unreal Editor is not killed after you stop debugging
I don't think so. Sometimes when I'm just testing stuff I don't run debug. I just Build it using one of the VSCode Build Tasks. Once it's done Building successfully I just go to the project folder and double click the *.uproject file to run the project. You must build the 'Editor' suffix build if you want it to load into the Editor.
That's the Build task I usually run on Windows. TestFps is my project name.
Oh, ok, so I don't need to worry about the plain debug one.
I guess if I need to inspect variables in VSCode the editor is always killed then. I was hoping I could save the time of restarting the editor each time I hit stop in the debugger. Oh well...
Hey, so it's been a while. I just updated the extension and am getting errors on includes just like before.
Settings are as follows:
"UEIntellisenseFixes.enableFixes": true, "UEIntellisenseFixes.cppStandard": "c++17", "C_Cpp.default.intelliSenseMode": "macos-clang-x64", "workbench.editor.untitled.hint": "hidden", "C_Cpp.loggingLevel": "Debug", "UEIntellisenseFixes.compiler.path": "/usr/bin/clang++",
Also, your extension is reporting some other problems.
' Found Unreal Engine v5.0.3
Error : 0: Couldn't create compileCommands from /Users/lmnicosia/CIS/Projects/UE5/Test3/.vscode/compileCommands_Default.json with key:MAIN! (not an error with UE 4.25.#)
Error : Did not create any compile commands with keyMAIN! (not an error with UE 4.25.#)
Error : Error in loadCompileCommandsFromWorkspace!
Error : This fixable project hasn't been initialized properly and is invalid.
Error : Couldn't create file watchers!
Number of error messages: 5 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. '
I did update XCode recently... Maybe that broke everything... Any ideas?
What XCode version? I know XCode 14/clang 14.0.0 can cause errors on Mac( and Windows).
Was this a new project you're trying?
Indeed. I am in the process of downgrading. I bloody hate this walled garden of Eden!
What XCode version? I know XCode 14/clang 14.0.0 can cause errors on Mac
Really? What errors? I'm on 14 as well. Ah, I see...
https://stackoverflow.com/questions/73750260/apples-clang-cant-use-with-stdtuple
I don’t code on a Mac but from what I’ve heard it’s advised to not use apple clang and to install clang from homebrew I'm having the same issue. Apple clang with clib++ (from xcode) appears broken in this regard.
https://embeddedartistry.com/blog/2017/02/24/installing-llvm-clang-on-osx/
You could install brew llvm/clang with:
brew update
brew install llvm
Will print the following info at the end of brew install:
llvm is keg-only, which means it was not symlinked into /opt/homebrew, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
For compilers to find llvm you may need to set: export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
This will normally install llvm under /usr/local/opt/llvm for not to colide with the apple clang.
$ ls /opt/homebrew/opt/llvm/bin
clang
clang++
...
$ /opt/homebrew/opt/llvm/bin/clang++ --version
Homebrew clang version 15.0.3
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
To work with CMake
You can either set /usr/local/opt/llvm/bin in front of PATH or set CC and CXX environment variables appropriately.
On my machine I have compiled the newest LLVM from sources , installed it under /usr/local/opt/myllvm and set CC/CXX to clang/clang++.
See https://cmake.org/cmake/help/latest/envvar/CXX.html
Perhaps another option:
https://code.visualstudio.com/docs/cpp/config-clang-mac
The first time you run your program, the C++ extension creates tasks.json
, which you'll find in your project's .vscode
folder. tasks.json
stores build configurations.
Your new tasks.json file
should look similar to the JSON below:
See https://go.microsoft.com/fwlink/?LinkId=733558 for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
Change to sth similar to the following (see https://discourse.llvm.org/t/switch-from-apple-clang-to-homebrew-clang-in-vs-code-configuration/63314)
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/local/Cellar/llvm/13.0.1_1/bin/clang",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
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