Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARNING:compdb.includedb:libmodbus/include/modbus.h: could not resolve header: "stdint.h" #25

Open
gianmarcoodorizzi opened this issue Mar 10, 2022 · 1 comment

Comments

@gianmarcoodorizzi
Copy link

gianmarcoodorizzi commented Mar 10, 2022

Hello,

I am using Visual Studio Code with vscode-clangd extension, which reads a compile_commands.json file and sets up the project based on that.
I noticed, however, that it fails to recognize includes inside header files that do not have a corresponding source file:

'string' file not found

when including <string>.

Hence, I am using your tool.
My (simplified) project directory structure is as follows:

├── MyExe
├── Makefile
├── build
│   ├── compile_commands.json
│   └── src
│       ├── Module1
│       │   ├── Module1.d
│       │   └── Module1.o
│       ├── Module2
│       │   ├── Module2.d
│       │   └── Module2.o
│       ├── main.d
│       ├── main.o
├── libmodbus
│   ├── include
│   │   ├── modbus-rtu.h
│   │   ├── modbus-tcp.h
│   │   ├── modbus-version.h
│   │   └── modbus.h
│   └── lib
│       └── libmodbus.a
├── src
│   ├── Module1
│   │   ├── Module1.cpp
│   │   └── Module1.hpp
│   ├── Module2
│   │   ├── Module2.cpp
│   │   └── Module2.hpp
│   ├── config.h
│   ├── json.hpp
│   ├── main.cpp
│   ├── version.hpp
│   ├── zhelpers.hpp
│   └── zmq.hpp`

When issue the command, this is what I get:

$ compdb --trace -p build/ list > compile_commands.json
WARNING:compdb.includedb:libmodbus/include/modbus.h: could not resolve header: "stdint.h"
WARNING:compdb.includedb:src/Module1/Module1.hpp: could not resolve header: "zmq_utils.h"
WARNING:compdb.includedb:src/Module2/Module2.cpp: could not resolve header: "time.h"

The original compilation database contains a list of similar entries:

{
    "arguments": [
      "/opt/fslc-framebuffer/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-g++",
      "-mthumb",
      "-mfpu=neon",
      "-mfloat-abi=hard",
      "-mcpu=cortex-a9",
      "-fstack-protector-strong",
      "-D_FORTIFY_SOURCE=2",
      "-Wformat",
      "-Wformat-security",
      "-Werror=format-security",
      "--sysroot=/opt/fslc-framebuffer/3.1/sysroots/cortexa9t2hf-neon-fslc-linux-gnueabi",
      "-DSPDLOG_COMPILED_LIB",
      "-Wall",
      "-Wextra",
      "-pedantic-errors",
      "-Wno-psabi",
      "-std=c++17",
      "-Ilibmodbus/include",
      "-Isrc",
      "-c",
      "-MTbuild/src/main.o",
      "-o",
      "build/src/main.o",
      "src/main.cpp"
    ],
    "directory": "/home/user/git/project",
    "file": "/home/user/git/project/src/main.cpp",
    "output": "/home/git/project/build/src/main.o"
  }

while the modified one has:

{
  "directory": "/home/user/git/project",
  "command": "/opt/fslc-framebuffer/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fslc-framebuffer/3.1/sysroots/cortexa9t2hf-neon-fslc-linux-gnueabi -DSPDLOG_COMPILED_LIB -Wall -Wextra -pedantic-errors -Wno-psabi -std=c++17 -Ilibmodbus/include -Isrc -c -MTbuild/src/main.o -o build/src/main.o src/main.cpp",
  "file": "/home/user/git/project/src/main.cpp",
  "output": "/home/git/project/build/src/main.o"
}

as well as entries for headers:

{
  "directory": "/home/user/git/project",
  "command": "/opt/fslc-framebuffer/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fslc-framebuffer/3.1/sysroots/cortexa9t2hf-neon-fslc-linux-gnueabi -DSPDLOG_COMPILED_LIB -Wall -Wextra -pedantic-errors -Wno-psabi -std=c++17 -Ilibmodbus/include -Isrc -MTbuild/src/main.o -c /home/user/git/project/src/zmq.hpp",
  "file": "/home/user/git/project/src/zmq.hpp"
}

Is there something wrong with what I am doing here? Thank you in advance.

@Sarcasm
Copy link
Owner

Sarcasm commented Mar 10, 2022

Not sure, but I think neither clangd nor compdb understand well the --sysroot part, so the system headers aren't found.
If you manage to make clangd work, you shouldn't need compdb, so that's what I would focus on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants