microsoft / microsoft/vscode-cmake-tools

Include errors for multiple C++ standard headers on macOS

Open
#2,900 9 comments 0 reactions 0 assignees View on GitHub
Feature: cpptools integration upstream
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

IntelliSense is reporting multiple include errors when I try to include certain C++ standard headers on macOS (see attached image).

For example:
- `#include ` -> `cannot open source file "wchar.h" (dependency of "unordered_map")`
- `#include ` -> `cannot open source file "stdio.h" (dependency of "iostream")`

This has been reported before without being fixed:
- #1873 @bobbrow
- https://github.com/microsoft/vscode-cpptools/issues/4350

**Repro steps:**
*main.cpp*

```
#include
#include
#include
#include
#include
#include

int main()
{
return 0;
}
```

*settings.json*
```
{
"cmake.preferredGenerators":[
"Xcode",
"Visual Studio 16 2019",
"Ninja",
"Unix Makefiles"
],
"files.associations": {
},
"cmake.configureOnOpen": true,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
```

*CMakeLists.txt*
```
cmake_minimum_required(VERSION 3.0.0)
project(Test VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(Test main.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
```

**Restart VS Code** and `Cmake: Delete Cache and Reconfigure`

### CMake Tools Diagnostics

```shell
{
"os": "darwin",
"vscodeVersion": "1.74.1",
"cmtVersion": "1.12.27",
"configurations": [
{
"folder": "/Users//test",
"cmakeVersion": "3.25.1",
"configured": true,
"generator": "Xcode",
"usesPresets": false,
"compilers": {
"C": "/usr/bin/clang",
"CXX": "/usr/bin/clang++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug",
"Release",
"MinSizeRel",
"RelWithDebInfo"
],
"requests": [
"file:///Users//test/main.cpp"
],
"responses": [
{
"uri": "file:///Users//test/main.cpp",
"configuration": {
"includePath": [],
"defines": [],
"compilerPath": "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang++",
"compilerArgs": [],
"compilerFragments": [
"-g"
]
}
}
],
"partialMatches": [],
"targetCount": 7,
"executablesCount": 1,
"librariesCount": 0,
"targets": [
{
"name": "ALL_BUILD",
"type": "UTILITY"
},
{
"name": "Continuous",
"type": "UTILITY"
},
{
"name": "Experimental",
"type": "UTILITY"
},
{
"name": "Nightly",
"type": "UTILITY"
},
{
"name": "NightlyMemoryCheck",
"type": "UTILITY"
},
{
"name": "Test",
"type": "EXECUTABLE"
},
{
"name": "ZERO_CHECK",
"type": "UTILITY"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
```

### Debug Log

```shell
[main] Building folder: test
[main] Saving open files before configure/build
[build] Starting build
[driver] Start build ALL_BUILD
[proc] Executing command: /Applications/CMake.app/Contents/bin/cmake --build /Users//test/build --config Debug --target ALL_BUILD -j 6 --
[build] Command line invocation:
[build] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project Test.xcodeproj build -target ALL_BUILD -parallelizeTargets -configuration Debug -jobs 6 -hideShellScriptEnvironment
[build]
[build] User defaults from command line:
[build] HideShellScriptEnvironment = YES
[build] IDEBuildOperationMaxNumberOfConcurrentCompileTasks = 6
[build] IDEPackageSupportUseBuiltinSCM = YES
[build]
[build] Build Preparation
[build] Build task concurrency set to 6 via user default IDEBuildOperationMaxNumberOfConcurrentCompileTasks
[build]
[build] Computing target dependency graph and provisioning inputs
[build]
[build] Create build description
[build] Build description signature: 82f1230ba2216038cf67b2233891937f
[build] Build description path: /Users//test/build/build/XCBuildData/82f1230ba2216038cf67b2233891937f-desc.xcbuild
[build]
[build] note: Building targets in dependency order
[build] note: Run script build phase 'Generate CMakeFiles/ZERO_CHECK' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ZERO_CHECK' from project 'Test')
[build] WriteAuxiliaryFile /Users//test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh (in target 'ZERO_CHECK' from project 'Test')
[build] cd /Users//test
[build] write-file /Users//test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh
[build]
[build] PhaseScriptExecution Generate\ CMakeFiles/ZERO_CHECK /Users//test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh (in target 'ZERO_CHECK' from project 'Test')
[build] cd /Users//test
[build] /bin/sh -c /Users//test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh
[build] make: `/Users//test/build/CMakeFiles/cmake.check_cache' is up to date.
[build]
[build] WriteAuxiliaryFile /Users//test/build/build/Test.build/Debug/DerivedSources/Entitlements.plist (in target 'Test' from project 'Test')
[build] cd /Users//test
[build] write-file /Users//test/build/build/Test.build/Debug/DerivedSources/Entitlements.plist
[build]
[build] ProcessProductPackaging "" /Users//test/build/build/Test.build/Debug/Test.xcent (in target 'Test' from project 'Test')
[build] cd /Users//test
[build]
[build] Entitlements:
[build]
[build] {
[build] "com.apple.application-identifier" = "";
[build] "com.apple.security.get-task-allow" = 1;
[build] }
[build]
[build] builtin-productPackagingUtility -entitlements -format xml -o /Users//test/build/build/Test.build/Debug/Test.xcent
[build]
[build] ProcessProductPackagingDER /Users//test/build/build/Test.build/Debug/Test.xcent /Users//test/build/build/Test.build/Debug/Test.xcent.der (in target 'Test' from project 'Test')
[build] cd /Users//test
[build] /usr/bin/derq query -f xml -i /Users//test/build/build/Test.build/Debug/Test.xcent -o /Users//test/build/build/Test.build/Debug/Test.xcent.der --raw
[build]
[build] CompileC /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/main.o /Users//test/main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Test' from project 'Test')
[build] cd /Users//test
[build] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target x86_64-apple-macos13.0 -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -I/Users//test/build/Debug/include -I/Users//test/build/build/Test.build/Debug/DerivedSources-normal/x86_64 -I/Users//test/build/build/Test.build/Debug/DerivedSources/x86_64 -I/Users//test/build/build/Test.build/Debug/DerivedSources -F/Users//test/build/Debug -MMD -MT dependencies -MF /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/main.d --serialize-diagnostics /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/main.dia -c /Users//test/main.cpp -o /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/main.o
[build]
[build] WriteAuxiliaryFile /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/Test.LinkFileList (in target 'Test' from project 'Test')
[build] cd /Users//test
[build] write-file /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/Test.LinkFileList
[build]
[build] Ld /Users//test/build/Debug/Test normal (in target 'Test' from project 'Test')
[build] cd /Users//test
[build] /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -L/Users//test/build/build/EagerLinkingTBDs -L/Users//test/build/Debug -F/Users//test/build/build/EagerLinkingTBDs -F/Users//test/build/Debug -filelist /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/Test.LinkFileList -Xlinker -object_path_lto -Xlinker /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/Test_lto.o -Xlinker -no_deduplicate -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users//test/build/build/Test.build/Debug/Objects-normal/x86_64/Test_dependency_info.dat -o /Users//test/build/Debug/Test
[build]
[build] CodeSign /Users//test/build/Debug/Test (in target 'Test' from project 'Test')
[build] cd /Users//test
[build]
[build] Signing Identity: "-"
[build]
[build] /usr/bin/codesign --force --sign - --entitlements /Users//test/build/build/Test.build/Debug/Test.xcent --timestamp\=none --generate-entitlement-der /Users//test/build/Debug/Test
[build]
[build] RegisterExecutionPolicyException /Users//test/build/Debug/Test (in target 'Test' from project 'Test')
[build] cd /Users//test
[build] builtin-RegisterExecutionPolicyException /Users//test/build/Debug/Test
[build]
[build] note: Run script build phase 'Generate CMakeFiles/ALL_BUILD' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ALL_BUILD' from project 'Test')
[build] WriteAuxiliaryFile /Users//test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh (in target 'ALL_BUILD' from project 'Test')
[build] cd /Users//test
[build] write-file /Users//test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh
[build]
[build] PhaseScriptExecution Generate\ CMakeFiles/ALL_BUILD /Users//test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh (in target 'ALL_BUILD' from project 'Test')
[build] cd /Users//test
[build] /bin/sh -c /Users//test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh
[build] Build all projects
[build]
[build] ** BUILD SUCCEEDED **
[build]
[cmakefileapi-parser] Read reply folder: /Users//test/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-d4f8e11d4dbd8a80f49c.json","cmakeFiles-v1-7a4b20fe0978c164b346.json","codemodel-v2-05a835ab48ca57f73c54.json","directory-.-Debug-f5ebdc15457944623624.json","directory-.-MinSizeRel-f5ebdc15457944623624.json","directory-.-RelWithDebInfo-f5ebdc15457944623624.json","directory-.-Release-f5ebdc15457944623624.json","index-2022-12-19T23-22-31-0885.json","target-ALL_BUILD-Debug-9033979d823adfbf080f.json","target-ALL_BUILD-MinSizeRel-9033979d823adfbf080f.json","target-ALL_BUILD-RelWithDebInfo-9033979d823adfbf080f.json","target-ALL_BUILD-Release-9033979d823adfbf080f.json","target-Continuous-Debug-3f06cb7ed23b4e8ecf5c.json","target-Continuous-MinSizeRel-3f06cb7ed23b4e8ecf5c.json","target-Continuous-RelWithDebInfo-3f06cb7ed23b4e8ecf5c.json","target-Continuous-Release-3f06cb7ed23b4e8ecf5c.json","target-Experimental-Debug-d73d5065e4d78beae069.json","target-Experimental-MinSizeRel-d73d5065e4d78beae069.json","target-Experimental-RelWithDebInfo-d73d5065e4d78beae069.json","target-Experimental-Release-d73d5065e4d78beae069.json","target-Nightly-Debug-f56731a0f6c2711e870a.json","target-Nightly-MinSizeRel-f56731a0f6c2711e870a.json","target-Nightly-RelWithDebInfo-f56731a0f6c2711e870a.json","target-Nightly-Release-f56731a0f6c2711e870a.json","target-NightlyMemoryCheck-Debug-8bd7e41cf7e167740287.json","target-NightlyMemoryCheck-MinSizeRel-8bd7e41cf7e167740287.json","target-NightlyMemoryCheck-RelWithDebInfo-8bd7e41cf7e167740287.json","target-NightlyMemoryCheck-Release-8bd7e41cf7e167740287.json","target-Test-Debug-43130db3c4791abba08a.json","target-Test-MinSizeRel-36ccb6b881213f765efa.json","target-Test-RelWithDebInfo-614eb79353e574a29c91.json","target-Test-Release-38ead0a1c4af08a72f14.json","target-ZERO_CHECK-Debug-a5d02d478828279fa76a.json","target-ZERO_CHECK-MinSizeRel-a5d02d478828279fa76a.json","target-ZERO_CHECK-RelWithDebInfo-a5d02d478828279fa76a.json","target-ZERO_CHECK-Release-a5d02d478828279fa76a.json","toolchains-v1-ad270cc0d653ffa2f711.json"]
[build] Build finished with exit code 0
[cache] Reading CMake cache file /Users//test/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [5148] cmake.build finished (returned 0)
```

### Additional Information

Screenshot 2022-12-19 at 23 12 15

Contributor guide

Open the contributing guide

Research direction

Reproduce the report with main.cpp, settings.json, and CMakeLists.txt, then inspect the CMake Tools diagnostics and cpptoolsIntegration response for the empty includePath. Compare the reported IntelliSense errors for the standard headers with the compiler command shown in the debug log; done means the headers resolve without include errors in the described macOS setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, macos, vscode
Domain
build-system, developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.