Skip to content

Non-standard header files may not be recognized properly #142

Description

@Season0518

Observed behavior

I'm trying to migrate from clangd to ccls recently. I configured gcc-toolchain as shown in the wiki, but why doesn't it recognize gcc's header files like clangd does?

image

Compile_commands.json

[
{
  "directory": "/Users/season/CLionProjects/new_project/build",
  "command": "/opt/homebrew/bin/aarch64-apple-darwin24-g++-14 -DCMAKE_INTDIR=\\\"Debug\\\" -g -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -mmacosx-version-min=15.1 -o CMakeFiles/test.dir/Debug/main.cpp.o -c /Users/season/CLionProjects/new_project/main.cpp",
  "file": "/Users/season/CLionProjects/new_project/main.cpp",
  "output": "CMakeFiles/test.dir/Debug/main.cpp.o"
},
{
  "directory": "/Users/season/CLionProjects/new_project/build",
  "command": "/opt/homebrew/bin/aarch64-apple-darwin24-g++-14 -DCMAKE_INTDIR=\\\"Release\\\" -O3 -DNDEBUG -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -mmacosx-version-min=15.1 -o CMakeFiles/test.dir/Release/main.cpp.o -c /Users/season/CLionProjects/new_project/main.cpp",
  "file": "/Users/season/CLionProjects/new_project/main.cpp",
  "output": "CMakeFiles/test.dir/Release/main.cpp.o"
},
{
  "directory": "/Users/season/CLionProjects/new_project/build",
  "command": "/opt/homebrew/bin/aarch64-apple-darwin24-g++-14 -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" -O2 -g -DNDEBUG -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk -mmacosx-version-min=15.1 -o CMakeFiles/test.dir/RelWithDebInfo/main.cpp.o -c /Users/season/CLionProjects/new_project/main.cpp",
  "file": "/Users/season/CLionProjects/new_project/main.cpp",
  "output": "CMakeFiles/test.dir/RelWithDebInfo/main.cpp.o"
}
]

CMakeLists

cmake_minimum_required(VERSION 3.25)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)

project(cpp_test LANGUAGES C CXX)

add_executable(test)
target_sources(test PRIVATE main.cpp)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <iostream>

int main() {
  
}

ccls output:

Server CWD is /Users/season/CLionProjects/new_project
21:20:44                initialize.cc:330 I initialize in directory /Users/season/CLionProjects/new_project with uri file:///Users/season/CLionProjects/new_project
21:20:44                initialize.cc:353 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"","cache":{"directory":".ccls-cache","format":"binary","hierarchicalPath":false,"retainInMemory":2},"capabilities":{"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"foldingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}},"clang":{"excludeArgs":[],"extraArgs":["/opt/homebrew/bin/aarch64-apple-darwin24-g++-14"],"pathMappings":[],"resourceDir":""},"client":{"diagnosticsRelatedInformation":true,"hierarchicalDocumentSymbolSupport":true,"linkSupport":true,"snippetSupport":false},"codeLens":{"localVariables":false},"completion":{"caseSensitivity":2,"detailedLabel":false,"dropOldRequests":true,"duplicateOptional":false,"filterAndSort":true,"include":{"blacklist":[],"maxPathSize":37,"suffixWhitelist":[".h",".hpp",".hh",".inc",".h",".hpp",".hh"],"whitelist":[]},"maxNum":100,"placeholder":true},"diagnostics":{"blacklist":[],"onChange":1000,"onOpen":0,"onSave":0,"spellChecking":true,"whitelist":[]},"highlight":{"largeFileSize":2097152,"rainbow":0,"blacklist":[],"whitelist":[]},"index":{"blacklist":[],"comments":2,"initialNoLinkage":false,"initialBlacklist":[],"initialWhitelist":[],"maxInitializerLines":15,"multiVersion":0,"multiVersionBlacklist":[],"multiVersionWhitelist":[],"name":{"suppressUnwrittenScope":false},"onChange":false,"parametersInDeclarations":true,"threads":0,"trackDependency":2,"whitelist":[]},"request":{"timeout":5000},"session":{"maxNum":10},"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"maxNum":2000}}
21:20:44                initialize.cc:386 I use -resource-dir=/opt/homebrew/opt/llvm/lib/clang/19
21:20:44                initialize.cc:418 I workspace folder: /Users/season/CLionProjects/new_project/
21:20:44                initialize.cc:443 I start 12 indexers
21:20:44                initialize.cc:447 I dispatch initial index requests
21:20:44                  pipeline.cc:510 I loaded project. Refresh semantic highlight for all working file.
21:20:44              sema_manager.cc:776 I create session for /Users/season/CLionProjects/new_project/main.cpp
21:20:45                  pipeline.cc:386 I parse /Users/season/CLionProjects/new_project/main.cpp error:1 'iostream' file not found
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_null.h (delta: 1)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_wchar_t.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_header_macro.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_nullptr_t.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_ptrdiff_t.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/stddef.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_offsetof.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_size_t.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /opt/homebrew/Cellar/llvm/19.1.4/lib/clang/19/include/__stddef_max_align_t.h (delta: 0)
21:20:45                  pipeline.cc:397 I store index for /Users/season/CLionProjects/new_project/main.cpp (delta: 0)
21:20:55                  pipeline.cc:386 I parse /Users/season/CLionProjects/new_project/main.cpp error:1 'bits/stdc++.h' file not found
21:20:55                  pipeline.cc:397 I store index for /Users/season/CLionProjects/new_project/main.cpp (delta: 1)
21:20:59                  pipeline.cc:386 I parse /Users/season/CLionProjects/new_project/main.cpp error:1 'bits/stdc++.h' file not found
21:20:59                  pipeline.cc:397 I store index for /Users/season/CLionProjects/new_project/main.cpp (delta: 1)
21:21:08                  pipeline.cc:386 I parse /Users/season/CLionProjects/new_project/main.cpp error:1 'bits/stdc++.h' file not found
21:21:08                  pipeline.cc:397 I store index for /Users/season/CLionProjects/new_project/main.cpp (delta: 1)

Expected behavior

The header file is recognized normally

Screenshot from clangd
image

Steps to reproduce

  1. Create a empty folder
  2. Create CMakeLists and main.cpp
  3. Configure Project

System information

  • ccls version (git describe --tags):
    Homebrew ccls version
    clang version 19.1.4
  • OS: Macos 15.1.1 (24B91)
  • Editor: VSCode
  • vscode-ccls version: v0.1.29

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions