推荐 最新
大厂球袋

C语言编译时出现invalid application of 'sizeof' to an incomplete type 'struct tcphdr'怎么办?

Hello! 简而言之,所谓"struct tcphdr"是一个来自外部的被include的库文件的结构体. 而且它这个结构体的构造有点诡异.我不知道什么是__extension__ union,这会让它更难处理吗? struct tcphdr { __extension__ union { struct { uint16_t th_sport; /* source port */ uint16_t th_dport; /* destination port */ tcp_seq th_seq; /* sequence number */ tcp_seq th_ack; /* acknowledgement number */ # if __BYTE_ORDER == __LITTLE_ENDIAN uint8_t th_x2:4; /* (unused) */ uint8_t th_off:4; /* data offset */ # endif # if __BYTE_ORDER == __BIG_ENDIAN uint8_t th_off:4; /* data offset */ uint8_t th_x2:4; /* (unused) */ # endif uint8_t th_flags; # define TH_FIN 0x01 # define TH_SYN 0x02 # define TH_RST 0x04 # define TH_PUSH 0x08 # define TH_ACK 0x10 # define TH_URG 0x20 uint16_t th_win; /* window */ uint16_t th_sum; /* checksum */ uint16_t th_urp; /* urgent pointer */ }; struct { uint16_t source; uint16_t dest; uint32_t seq; uint32_t ack_seq; # if __BYTE_ORDER == __LITTLE_ENDIAN uint16_t res1:4; uint16_t doff:4; uint16_t fin:1; uint16_t syn:1; uint16_t rst:1; uint16_t psh:1; uint16_t ack:1; uint16_t urg:1; uint16_t res2:2; # elif __BYTE_ORDER == __BIG_ENDIAN uint16_t doff:4; uint16_t res1:4; uint16_t res2:2; uint16_t urg:1; uint16_t ack:1; uint16_t psh:1; uint16_t rst:1; uint16_t syn:1; uint16_t fin:1; # else # error "Adjust your defines" # endif uint16_t window; uint16_t check; uint16_t urg_ptr; }; }; }; 我不能在程序里对它进行sizeof,或者对指向它的类型的地址进行"->"操作,无法编译通过. 问题是这是官方给的源码,它肯定自己编译是通过的啊?是我的编译选项有问题吗?我是本地交叉编译. 而且,sizeof实在不行的话我可以直接把它全改成具体的数字,但"->"这个操作我不可能把它混过去. 怎么办好呢?

17
1
0
浏览量330
明道

能帮看一下这个"multiple definition"的make报错吗?

/media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: util.o:/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373: multiple definition of `tcp_lws_cache'; snort.o:/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373: first defined here /media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: preprocessors/Stream6/libstream6.a(stream_common.o):/home/zhzhy/snort/snort-2.9.81/build/src/preprocessors/Stream6/../../../../src/preprocessors/Stream6/stream_common.h:376: multiple definition of `ip_lws_cache'; snort.o:/home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:376: first defined here 所幸这些错误都是"multiple definition of...first defined here"的形式.足足几十条,随便选了两条. 比方说第一条 /media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: util.o: /home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373: multiple definition of `tcp_lws_cache'; snort.o: /home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:373: first defined here 链接器ld认为,两个.o文件中包含了重复定义的标识符,但这两个标识符的定义位置都是某个文件的373行,这是同一个定义,这是什么问题?同一个定义不就是一样东西吗? 还有第二条. /media/zhzhy/entertain/学习/编程语言/snort/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/../lib/gcc/arm-none-linux-gnueabihf/10.3.1/../../../../arm-none-linux-gnueabihf/bin/ld: preprocessors/Stream6/libstream6.a(stream_common.o): /home/zhzhy/snort/snort-2.9.81/build/src/preprocessors/Stream6/../../../../src/preprocessors/Stream6/stream_common.h:376: multiple definition of `ip_lws_cache'; snort.o: /home/zhzhy/snort/snort-2.9.81/build/src/../../src/preprocessors/Stream6/stream_common.h:376: first defined here 几乎是一回事,只不过是从两个.o文件变成了一个.a文件和.o文件. 这种问题是怎么回事呢?恳请赐教.

11
1
0
浏览量269
CO_co

windows下pip安装onnx编译出错,cmake编译 文件名或扩展名太长,求解?

windows下pip安装onnx编译出错,cmake编译 文件名或扩展名太长 求解决方法 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241008/a5e336ea586350475fc4c148fa174b66.png)

0
1
0
浏览量212
米斯达

vue3编译过程的调试,怎么才能调试啊?

最近发现vue3在在"mode"为"function"和"module"下有时候编译的结果不一样。 于是想调试一下vue3的编译过程,特别是插值表达式中"变量"被替换为诸如ctx.aa 这种的过程。 折腾了好久,发现只能调试"mode"为"function"时候的过程,在vite或者vue-cli项目中调试"mode"为"module",但是到模版的编译时候,只能看见openBlock 函数和setupBlock 函数,但是看不见render 函数的生成,也就是看不见编译中compile transform generate三个过程,不知道为啥。 有没有大佬在vite项目和vue-cli项目中能成功调试到编译过程的。

0
1
0
浏览量194
走你啊啊啊啊啊

如何使用mxe将centos下的C++项目(使用了pybind)编译成windows下的可执行文件?

如何使用mxe将centos下的C++项目(使用了pybind)编译成windows下的可执行文件 如题,现在我有一个C++项目,需要#include,pybind.h会引用Python.h 但是Python的linux版与windows版是不一样的,比如linux版python会引用linux中的sys/net.h头文件,该头文件并不存在于windows系统中,直接使用linux版python编译会报出reference error 为了解决这个问题,我尝试了将windows下python打包放进linux系统下,但是CMake在find_package(Python3 REQUIRED)时仍然寻找到的是linux下的python而不是我打包的windows版python。 除此以外我还尝试过修改 pybind11_DIR, Python3_DIR来使CMake能够指向我希望的python,这个做法的结果是在最后链接阶段会出现undefined reference的报错。 请问我该如何做才能将该项目成功地打包成exe文件

0
1
0
浏览量138
momo

编译 php,报错ld: symbol(s) not found for architecture arm64?

报错信息如下: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20240918/22fd17342441a398af83e04280992710.png) 在网上查找方案,没有找到有价值的信息,请问应该如何解决这种情况呢?

0
1
0
浏览量131