First change the cpp dependency
Enter the c_cpp_properties.json file and change "cppStandard" on line 16 to "c++17"
- Then add the local ROS library to the search path
Add "/opt/ros/kinetic/include/**" to line 8 "includePath", note that here you need to change kinetic to your own ros version
- The entire c_cpp_properties.json file code is placed here (everyone remember to change kinetic to your own ros version)
{ "configurations": [ { "browse": { "databaseFilename": "${default}", "limitSymbolsToIncludedHeaders": false }, "includePath": [ "/opt/ros/kinetic/include/**", "/usr/include/**" ], "name": "ROS", "intelliSenseMode": "gcc-x64", "compilerPath": "/usr/bin/gcc", "cStandard": "gnu11", "cppStandard": "c++17" } ], "version": 4 }
After the change is made, it will be automatically completed when writing the code