'vscode report undefined symbol which has been actually included
The source code is very simple.
#include <signal.h>
void main() {
sigset_t set;
}
The signal.h has been included in which sigset_t should have been defined. But vscode still report a problem.
identifier "sigset_t" is undefined
The config file is as below.
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++98",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
And the program can be successfully compiled with no error. Why does vscode report that error?
Solution 1:[1]
The problem here is that sigset_t is only defined if _POSIX_C_SOURCE is defined.
With the C standard that gcc uses by default, _POSIX_C_SOURCE is already defined. So compiling your program with gcc doesn't produce an error.
To solve this you can add "cStandard": "gnu11" to you config file, or add "defines": ["_POSIX_C_SOURCE=199309L"].
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++98",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
