Sample Header Ad - 728x90

__USE_POSIX and VS Code in WSL distro

0 votes
2 answers
1819 views
I'm learning C and in general I code with VS Code in Ubuntu. For convenience, I'm trying to migrate my learning materials to Windows where a lot of my other works happen, so I installed WSL 2 and its distro Ubuntu 18.04 LTS. After installing VS Code for Windows and its remote extension to work with WSL, I boot up a new WSL session in VS Code, install the C/C++ extension with IntelliSense then write a simple program like below just for demonstration:
#include 

int main()
{
    kill(-1, SIGKILL);
}
The problem with VS Code is that while the program compiles, its IntelliSense doesn't detect the kill function in the signal.h header. By further investigating the header file, I observe that the following part is darkened
#ifdef __USE_POSIX
extern int kill (__pid_t __pid, int __sig) __THROW;
#endif /* Use POSIX.  */
along with other parts where __USE_POSIX is checked, including but not limited to siginfo_t, struct sigaction. Is there a way to make VS Code recognise these macros/variables to enable IntelliSense's assistance?
Asked by dqtvictory (1 rep)
Jul 2, 2021, 09:47 AM
Last activity: Aug 19, 2024, 03:49 PM