Reputation: 83
I am using VS2019 on Windows to edit c++ code files. The code is for Linux OS and depends on headers like #include <sys/socket.h> There is no project file for the visual studio so I can only open it as directory with files. It does know includes stdint.h and windows.h but not sys/socket.h.
How set VS to know the standard Linux headers? And how to include and arbitrary files for the intellisense when there is no project file (I can not create one).
I do not intent to build anything only to make intellisense and code completion possible.
Upvotes: 1
Views: 372
Reputation: 23750
Linux header files in VS wihout project
Actually, <sys/socket.h>
is used for UNIX/Linux. And Windows cannot use it.
Instead, you should use <Winsock2.h>
on Windows and it corresponds to socket.h
on Linux. Also, do not forget to link against Ws2_32.lib
.
Suggestion
Use these:
#include<winsock2.h>
#pragma comment(lib, "Ws2_32.lib")
=====================
Update
I assume your project is cmake for linux.
First, you should install the related component for cmake in vs installer. See this document.
Then, add include_directories(${YOUR_DIRECTORY}) in
cmakelist.txtfile to include the directory of the
socket.h` library. See cmake project to include library directories.
After that, you could include that header in cpp file.
Upvotes: 1