我正在使用pcap代码,似乎在两个include中定义了struct udphdr。如何告诉GCC使用特定的?

最佳答案

如果要使用uh_ * elements,则必须使用-D_BSD_SOURCE宏作为gcc的参数,尽管会出现以下错误:

error: ‘struct udphdr’ has no member named ‘uh_sport’
error: ‘struct udphdr’ has no member named ‘uh_dport’
error: ‘struct udphdr’ has no member named ‘uh_ulen’
error: ‘struct udphdr’ has no member named ‘uh_sum’
error: ‘struct udphdr’ has no member named ‘uh_sum’

08-17 13:22