WebSocket #include errors detected. Please update your includePath - c++

I'm trying to work on WebSocket in C++ using websocketpp library. I have cloned this library https://github.com/zaphoyd/websocketpp in my system and build it using "cmake -G "MinGW Makefiles". Now the source code which I have created outside this repository.
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
void on_message(websocketpp::connection_hdl hdl, server::message_ptr msg) {
std::cout << msg->get_payload() << std::endl;
}
int main() {
server print_server;
print_server.set_message_handler(&on_message);
print_server.init_asio();
print_server.listen(9002);
print_server.start_accept();
print_server.run();
}
is throwing error:
fatal error: websocketpp/config/asio_no_tls.hpp: No such file or directory
#include <websocketpp/config/asio_no_tls.hpp>
although this file is available in directory. Since I'm not getting any issue with this line #include <websocketpp/server.hpp>. Clicking on option more I found this error
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit
Anyone help it out with what needs to be done. I'm editing it in VS code and using MinGW.
this is the properties.json file
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4

Related

Unable to include local C++ dependencies in VSCode

I am having an issue with writing code for my Robotic Operating System (ROS) project, however it's more related to dependency inclusion. Here is as far as I got with the code:
// ROS
#include <ros/ros.h>
// MoveIt
#include "moveit/moveit_ros/planning_interface/planning_scene_interface/include/*"
#include "moveit/moveit_ros/planning_scene_interface/planning_scene_interface.h"
#include <moveit/move_group_interface/move_group_interface.h>
// TF2
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
// The circle constant tau = 2*pi. One tau is one rotation in radians.
const double tau = 2 * M_PI;
int main(){
}
The issue is that dependency 2 through to 4 are not identified by VSCode. I attempted to include the necessary path within c_cpp_properties.json for dependency 2 as such:
"/home/george/ws_moveit/src/moveit/moveit_ros/planning_interface/planning_scene_interface/include/**"
The full c_cpp_properties.json looks as such:
{
"configurations": [
{
"browse": {
"databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db",
"limitSymbolsToIncludedHeaders": false
},
"includePath": [
"/home/george/ws_moveit/devel/include/**",
"/opt/ros/noetic/include/**",
"/home/george/ws_moveit/src/moveit/moveit_planners/chomp/chomp_motion_planner/include/**",
"/home/george/ws_moveit/src/geometric_shapes/include/**",
"/home/george/ws_moveit/src/moveit/moveit_planners/chomp/chomp_interface/include/**",
"/home/george/ws_moveit/src/moveit_resources/prbt_ikfast_manipulator_plugin/include/**",
"/home/george/ws_moveit/src/moveit/moveit_ros/benchmarks/include/**",
"/home/george/ws_moveit/src/moveit/moveit_plugins/moveit_ros_control_interface/include/**",
"/home/george/ws_moveit/src/moveit/moveit_ros/move_group/include/**",
"/home/george/ws_moveit/src/moveit/moveit_ros/occupancy_map_monitor/include/**",
"/home/george/ws_moveit/src/moveit/moveit_ros/robot_interaction/include/**",
"/home/george/ws_moveit/src/moveit/moveit_ros/moveit_servo/include/**",
"/home/george/ws_moveit/src/moveit/moveit_setup_assistant/include/**",
"/home/george/ws_moveit/src/moveit/moveit_plugins/moveit_simple_controller_manager/include/**",
"/home/george/ws_moveit/src/moveit_visual_tools/include/**",
"/home/george/ws_moveit/src/pick_place/include/**",
"/home/george/ws_moveit/src/moveit/moveit_planners/pilz_industrial_motion_planner/include/**",
"/home/george/ws_moveit/src/moveit/moveit_planners/pilz_industrial_motion_planner_testutils/include/**",
"/home/george/ws_moveit/src/rviz_visual_tools/include/**",
"/home/george/ws_moveit/src/srdfdom/include/**",
"/usr/include/**",
"/opt/ros/noetic/include",
"/home/george/ws_moveit/src/moveit/moveit_ros/planning_interface/planning_scene_interface/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++14",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
This hasn't resolved my issue.
The way the packages are structured could be found here: https://github.com/ros-planning/moveit. It is essentially identical to the way I have them structured on my drive, with the the difference being the inclusion of the home/user directory.
The file in question should be located here:
https://github.com/ros-planning/moveit/tree/master/moveit_ros/planning_interface/planning_scene_interface/include/moveit/planning_scene_interface
Am I missing some detail or made an error?
#include "moveit/moveit_ros/planning_interface/planning_scene_interface/include/*"
Wildcards are not allowed in include statements, unless you have a very... weird preprocessor.
Reference the files you want to include directly, or use a master header file that directly contains all the files you want to include.

VSC - IntelliSense marks boolean operator as errors

IntelliSense is incorrectly marking boolean operators (and, or, etc.) As errors. Here is an example:
This is my c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
Anyone knows why this is happening?
With Visual C++, it looks like you need to add #include <iso646.h>.
C++ specifies bitand as an alternative spelling for &. In C, the alternative spelling is provided as a macro in the <iso646.h> header. In C++, the alternative spelling is a keyword; use of <iso646.h> or the C++ equivalent is deprecated. In Microsoft C++, the /permissive- or /Za compiler option is required to enable the alternative spelling.
After including the header file, it no longer errors:
Wikipedia also cites:
Some compilers, such as Microsoft Visual C++ have, at least in the past, required the header to be included in order to use these identifiers.

Configure VsCode Include Path for Protobuf installed with gRPC

I am using VsCode. I have gprc natively installed in the directory /grpc. I used their quickstart guide I have all the grpc header files needed; however, I cannot find all the files for protobuf. Within grpc I notice there is a /thirdparty/protobuf folder that I try to include but some artifacts are not found.
To note it compiles and runs perfectly. I am just setting up the include settings for c_cpp_properties.json for vscode linter.
Here is what I have
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${default}",
"${workspaceFolder}/include",
"${workspaceFolder}/grpc",
"${workspaceFolder}/build/protos",
"${workspaceFolder}",
"${workspaceFolder}/lib**",
"/grpc/include",
"/grpc/third_party",
"/grpc/third_party/protobuf"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu18",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-arm"
}
],
"version": 4
}
My protobufs cannot files such as the following for the generated protobuf files.
#include <google/protobuf/port_def.inc>
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/generated_enum_reflection.h>
#include <google/protobuf/unknown_field_set.h>
Another screenshot to sanity check that grpc includes from /grpc/includes are properly recognized by vscode.
Update
Download protobuf source file from github then include the path below in the json settings file.
"/protobuf/src/google/protobuf"

VSCode IntelliSense not recognising SDL_image extension library for SDL framework

I am trying to include the SDL_image extension library to SDL.framework in my project but VScode's IntelliSense keeps underlining my #include<SDL_image.h> with error lines. It produces the following error:
cannot open source file "SDL2/SDL.h" (dependency of "SDL_image.h")
I was successfully able to edit the c_cpp_properties.json includePath so IntelliSense recognised the SDL framework, but when trying to do the same thing with SLD_image it failed.
This is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/Library/Frameworks/SDL2_image.framework/Headers",
"/Library/Frameworks/SDL2.framework/Headers",
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
The problem wasn't with the c_cpp_properties.json but the SDL_image.h file. If you are using VScode (despite being on a mac) and encountering the same issue with IntelliSense, change the following include statements inside SDL_image.h from this:
#include <SDL2/SDL.h>
#include <SDL2/SDL_version.h>
#include <SDL2/begin_code.h>
#include <SDL2/close_code.h>
to this:
#include <SDL.h>
#include <SDL_version.h>
#include <begin_code.h>
#include <close_code.h>
Of note, I had the exact opposite issue working on Windows 10, just changed them arouind the other way.
From:
#include <SDL.h>
#include <SDL_version.h>
#include <begin_code.h>
#include <close_code.h>
To:
#include <SDL2/SDL.h>
#include <SDL2/SDL_version.h>
#include <SDL2/begin_code.h>
#include <SDL2/close_code.h>
as this is the exact path to the .h files

Incomplete type is not allowed (c++ VSCODE) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have simply created an Array a using container class. However, VScode's IntelliSense is showing an error. Here's an implementation of selection sort.
the contents of the c_cpp_properties.json file are as follows
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.16299.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
the code compiles and runs successfully. How do I fix the incorrect IntelliSense error?
Stop including bits/stdc++.h.
That's an implementation header for some toolchains. It's not for you.
Include the proper header instead:
#include <array>
(It's likely that your Intellisense engine does not have access to this internal header from Linuxy platforms.)
By the way, you're not allowed to choose names that begin with two underscores. So stop that too.