vscode编写ros ,#include<ros/ros.h>头文件时报错
首先在vscode扩展栏安装C/C++,CMake,CMake Tools,Code Runner,ROS,Chinese 这些插件
vscode中CTRL+P。
键入ext install ms-iot.vscode-ros 。按回车,等待下载完毕
鼠标点到报错的#include<ros/ros.h>,点击旁边会出现的灯泡,点击编辑 “include path”设置 ,进入c_cpp_properties.json选项,vscode会自动在配置文件夹中新建.vscode/文件夹,同时在里面初始化了c_cpp_properties.json文件
删除c_cpp_properties.json文件中的内容,用如下代码替换:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/melodic/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}