ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

VS Code include error for custom message headers, but builds fine

asked 2021-05-04 11:43:26 -0500

JulianR gravatar image

updated 2021-05-04 11:44:39 -0500

Hello,

I tried a lot but cannot get rid of the include errors of my custom messages in vs code. Everything builds fine, but vs code does not seem to find the generated headers. I edited the "includePath" in c_cpp_properties.json to point to the location of non default headers and it worked for everything but not my custom messages.

Here is a screenshot to show it. https://imgur.com/corGr4R

My c_cpp_properties.json looks like this:

{
    "configurations": [
        {
            "name": "ROS",
            "browse": {
                "databaseFilename": "",
                "limitSymbolsToIncludedHeaders": true
            },
            "includePath": [
                "/opt/ros/noetic/include",
                "/usr/include/**",
                "${workspaceFolder}/devel/include",
                "${workspaceFolder}/**",
                "/usr/local/include/opencv4",                   // OpenCV installed from source
                "/home/julian/freenect2/include/**",            // Freenect2
                "/home/julian/installers/FRI-Client-SDK_Cpp"    // SDK for FRI from KUKA
            ],
            "intelliSenseMode": "gcc-x64",
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

I would appreciate any help that might solve this issue.

Thanks

edit retag flag offensive close merge delete

Comments

2

instead of this

"${workspaceFolder}/devel/include"

may be you can try to put whole path of package? something like

"${workspaceFolder}/devel/include/<pkg-name>"

or

 "${workspaceFolder}/devel/include/**"

for me the last one is working.

aarsh_t gravatar image aarsh_t  ( 2021-05-04 14:45:28 -0500 )edit

Thanks for the answer. I tried both but they don't work for me either. I tried to reinstall the C/C++ Extension but it also did not work. Weird thing is that I have the same problem on both of my pcs.

JulianR gravatar image JulianR  ( 2021-05-04 16:19:54 -0500 )edit
1

One more thing came in my mind that, ${workspaceFolder} might not be pointing to the ros workspace (I am not sure how your vscode workspace has been set-up) . can you try to put direct path to devel folder of your ros workspace?

aarsh_t gravatar image aarsh_t  ( 2021-05-04 17:17:40 -0500 )edit

Thanks, I tried it but it did not work for me either. I Also tried to reinstall vscode from apt or software center and deleted all config files before, but also no luck.

JulianR gravatar image JulianR  ( 2021-05-05 03:14:31 -0500 )edit
1

Oh. No idea thn. sorry :(

aarsh_t gravatar image aarsh_t  ( 2021-05-05 12:07:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-04-02 03:33:54 -0500

JaFeKl gravatar image

Came across the same problem:

Adding "${workspaceFolder}/../../devel/include" to the include path in c_cpp_properties.json solved the problem

edit flag offensive delete link more

Comments

I think it will be different for each of us. and basically it should point to the /devel/include but it depends where your .vscode/ is located. you give the relative path wrt that. in your case I suppose you have the file tree something like below

catkin_ws
    |- build
    |- devel
    |- src
         |- my_meta_pkg
                   |- my_pkg_1
                           |- .vscode/
                           |- src/
                           |- include/
                           |- CMakeLists.txt
                           |- package.xml
                  |- my_pkg_2
aarsh_t gravatar image aarsh_t  ( 2022-04-02 05:47:52 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-05-04 11:43:26 -0500

Seen: 1,515 times

Last updated: Apr 02 '22