Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-27240

clangd does not find some headers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • Qt Creator 7.0.0
    • C/C++/Obj-C++ Support
    • None
    • macOS

    Description

      Clangd does not find the header string.h, but it should according to the second screenshot (there is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h)

       

      Why I running clang-tidy I get a more helpful error message:

      Analyzing "/Users/leanderSchulten/git_projekte/vcpkg-tool/src/vcpkg/binaryparagraph.cpp" [Clang-Tidy].
      Failed to analyze "/Users/leanderSchulten/git_projekte/vcpkg-tool/src/vcpkg/binaryparagraph.cpp": Clang-Tidy finished with exit code: 1.
      Command line: /Users/leanderSchulten/Qt/Qt Creator.app/Contents/Resources/libexec/clang/bin/clang-tidy '-config={Checks: '\''-*,bugprone-*,clang-*,cppcoreguidelines-avoid-*,cppcoreguidelines-c-copy-assignment-signature,cppcoreguidelines-explicit-virtual-functions,cppcoreguidelines-init-variables,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-macro-usage,cppcoreguidelines-narrowing-conversions,cppcoreguidelines-no-malloc,cppcoreguidelines-non-private-member-variables-in-classes,cppcoreguidelines-pro-*,cppcoreguidelines-slicing,cppcoreguidelines-special-member-functions,llvm-else-after-return,llvm-header-guard,llvm-include-order,llvm-namespace-comment,llvm-prefer-*,llvm-twine-local,modernize-avoid-*,modernize-concat-nested-namespaces,modernize-deprecated-*,modernize-loop-convert,modernize-make-*,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-*,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-*,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,modernize-use-using,performance-*,portability-*,readability-avoid-const-params-in-decls,readability-const-return-type,readability-container-size-empty,readability-convert-member-functions-to-static,readability-delete-null-pointer,readability-else-after-return,readability-function-size,readability-identifier-naming,readability-inconsistent-declaration-parameter-name,readability-isolate-declaration,readability-magic-numbers,readability-make-member-function-const,readability-misleading-indentation,readability-misplaced-array-index,readability-named-parameter,readability-non-const-parameter,readability-redundant-*,readability-simplify-*,readability-static-*,readability-string-compare,readability-uniqueptr-delete-release,readability-uppercase-literal-suffix,readability-use-anyofallof,-clang-diagnostic-*'\'', CheckOptions: []}' -export-fixes=/private/var/folders/2t/jzczznpx033c6tbrdt24ldhw0000gn/T/QtCreator-fiqHoT/clangtools-dldIzf/report-binaryparagraph.cpp-wGGevP /Users/leanderSchulten/git_projekte/vcpkg-tool/src/vcpkg/binaryparagraph.cpp -- -Wno-unknown-pragmas -Wno-unknown-warning-option -Wno-documentation-unknown-command -w -nostdinc -nostdinc++ -arch arm64 -g -arch arm64 -std=c++17 -fsyntax-only -m64 --target=aarch64-apple-darwin17.7.0 -x c++ -DFMT_LOCALE -DVCPKG_BASE_VERSION=2999-12-31 -DVCPKG_VERSION=unknownhash -I /Users/leanderSchulten/git_projekte/vcpkg-tool/include -I /Users/leanderSchulten/git_projekte/build-vcpkg-tool-No_QT-Debug/_deps/fmt-src/include -F /System/Library/Frameworks -F /Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 -isystem /usr/local/include -isystem '/Users/leanderSchulten/Qt/Qt Creator.app/Contents/Resources/libexec/clang/lib/clang/14.0.0/include' -isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
      Process Error: 5
      Output:
      warning: macro replacement list should be enclosed in parentheses [bugprone-macro-parentheses]
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:60:15: error: 'string.h' file not found [clang-diagnostic-error]
      #include_next <string.h>
                    ^~~~~~~~~~
      12:19:00: Error: Failed to analyze 1 files.
      

      When you google

      Fatal error: 'string h file not found #include_next <string.h>
      

      you get some results, they often suggest to set `-isysroot`.

      The file is build by cmake with the following command

      [ 17%] Building CXX object CMakeFiles/vcpkglib.dir/src/vcpkg/binaryparagraph.cpp.o
      /usr/bin/clang++ -DFMT_LOCALE -DVCPKG_BASE_VERSION=2999-12-31 -DVCPKG_VERSION=unknownhash -I/Users/leanderSchulten/git_projekte/vcpkg-tool/include -I/Users/leanderSchulten/git_projekte/build-vcpkg-tool-No_QT-Debug/_deps/fmt-src/include -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-redundant-move -Wmissing-prototypes -Wno-range-loop-analysis -include /Users/leanderSchulten/git_projekte/vcpkg-tool/include/pch.h -std=c++17 -MD -MT CMakeFiles/vcpkglib.dir/src/vcpkg/binaryparagraph.cpp.o -MF CMakeFiles/vcpkglib.dir/src/vcpkg/binaryparagraph.cpp.o.d -o CMakeFiles/vcpkglib.dir/src/vcpkg/binaryparagraph.cpp.o -c /Users/leanderSchulten/git_projekte/vcpkg-tool/src/vcpkg/binaryparagraph.cpp
      

       

      Ok I found a way to run the command without an error:

      Remove -nostdinc -nostdinc++ and all -isystem entries from the command line and add -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk, then the command finally runs without an error.

      Attachments

        Activity

          People

            kandeler Christian Kandeler
            autoantwort autoantwort
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: