VSCode无法从netinet正确导入头文件

时间:2018-10-24 14:50:30

标签: visual-studio-code

我正在尝试使用tcphdr头文件中定义的udphdrnetinet.h结构类型。

始终使用#include<netinet/tcphdr.h> VSCode仍显示消息:

pointer to incomplete class type is not allowed

在每个我要访问给定tcphdrudphdr结构的值的地方。

由于编译正常,我想我错过了在VSCode中配置的内容。

这是我当前的项目设置。

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/python3.5m",
                "/usr/include/netinet"
            ],
           "defines": [],
           "compilerPath": "/usr/bin/gcc",
           "cStandard": "c11",
           "cppStandard": "c++17",
           "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4,
}

最小示例:

#include <stdlib.h>
#include <stdio.h>

#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>

int main(int argc, char** argv) {
  struct tcphdr *test = malloc(sizeof(struct tcphdr));
  printf("%d\n", ntohs(test->dest));
  free(test);
  return 0;
}

0 个答案:

没有答案
相关问题