Skip to content

Include errors for multiple C++ standard headers on macOS #2900

Open
@tiagovcosta

Description

@tiagovcosta

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 <unordered_map> -> cannot open source file "wchar.h" (dependency of "unordered_map")
  • #include <iostream> -> cannot open source file "stdio.h" (dependency of "iostream")

This has been reported before without being fixed:

Repro steps:
main.cpp

#include <unordered_map>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cstdint>

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

{
  "os": "darwin",
  "vscodeVersion": "1.74.1",
  "cmtVersion": "1.12.27",
  "configurations": [
    {
      "folder": "/Users/<username>/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/<username>/test/main.cpp"
    ],
    "responses": [
      {
        "uri": "file:///Users/<username>/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

[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/<username>/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/<username>/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/<username>/test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh (in target 'ZERO_CHECK' from project 'Test')
[build]     cd /Users/<username>/test
[build]     write-file /Users/<username>/test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh
[build] 
[build] PhaseScriptExecution Generate\ CMakeFiles/ZERO_CHECK /Users/<username>/test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh (in target 'ZERO_CHECK' from project 'Test')
[build]     cd /Users/<username>/test
[build]     /bin/sh -c /Users/<username>/test/build/build/Test.build/Debug/ZERO_CHECK.build/Script-115BC4EF87E1E2A3870E421E.sh
[build] make: `/Users/<username>/test/build/CMakeFiles/cmake.check_cache' is up to date.
[build] 
[build] WriteAuxiliaryFile /Users/<username>/test/build/build/Test.build/Debug/DerivedSources/Entitlements.plist (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/test
[build]     write-file /Users/<username>/test/build/build/Test.build/Debug/DerivedSources/Entitlements.plist
[build] 
[build] ProcessProductPackaging "" /Users/<username>/test/build/build/Test.build/Debug/Test.xcent (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/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/<username>/test/build/build/Test.build/Debug/Test.xcent
[build] 
[build] ProcessProductPackagingDER /Users/<username>/test/build/build/Test.build/Debug/Test.xcent /Users/<username>/test/build/build/Test.build/Debug/Test.xcent.der (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/test
[build]     /usr/bin/derq query -f xml -i /Users/<username>/test/build/build/Test.build/Debug/Test.xcent -o /Users/<username>/test/build/build/Test.build/Debug/Test.xcent.der --raw
[build] 
[build] CompileC /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/main.o /Users/<username>/test/main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/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/<username>/test/build/Debug/include -I/Users/<username>/test/build/build/Test.build/Debug/DerivedSources-normal/x86_64 -I/Users/<username>/test/build/build/Test.build/Debug/DerivedSources/x86_64 -I/Users/<username>/test/build/build/Test.build/Debug/DerivedSources -F/Users/<username>/test/build/Debug -MMD -MT dependencies -MF /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/main.dia -c /Users/<username>/test/main.cpp -o /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/main.o
[build] 
[build] WriteAuxiliaryFile /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/Test.LinkFileList (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/test
[build]     write-file /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/Test.LinkFileList
[build] 
[build] Ld /Users/<username>/test/build/Debug/Test normal (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/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/<username>/test/build/build/EagerLinkingTBDs -L/Users/<username>/test/build/Debug -F/Users/<username>/test/build/build/EagerLinkingTBDs -F/Users/<username>/test/build/Debug -filelist /Users/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/Test.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/<username>/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/<username>/test/build/build/Test.build/Debug/Objects-normal/x86_64/Test_dependency_info.dat -o /Users/<username>/test/build/Debug/Test
[build] 
[build] CodeSign /Users/<username>/test/build/Debug/Test (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/test
[build]     
[build]     Signing Identity:     "-"
[build]     
[build]     /usr/bin/codesign --force --sign - --entitlements /Users/<username>/test/build/build/Test.build/Debug/Test.xcent --timestamp\=none --generate-entitlement-der /Users/<username>/test/build/Debug/Test
[build] 
[build] RegisterExecutionPolicyException /Users/<username>/test/build/Debug/Test (in target 'Test' from project 'Test')
[build]     cd /Users/<username>/test
[build]     builtin-RegisterExecutionPolicyException /Users/<username>/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/<username>/test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh (in target 'ALL_BUILD' from project 'Test')
[build]     cd /Users/<username>/test
[build]     write-file /Users/<username>/test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh
[build] 
[build] PhaseScriptExecution Generate\ CMakeFiles/ALL_BUILD /Users/<username>/test/build/build/Test.build/Debug/ALL_BUILD.build/Script-3A786CC8376774A37E05BE92.sh (in target 'ALL_BUILD' from project 'Test')
[build]     cd /Users/<username>/test
[build]     /bin/sh -c /Users/<username>/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/<username>/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/<username>/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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Pending Prioritization

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions