使用-std = c99进行编译时,struct ip_mreq消失

use*_*425 4 c sockets linux

在我们的一些linux盒子上用gcc -std = c99编译使得struct ip_mreq消失了(包含在netinet/in.h中)

我们应该使用其他一些界面吗?

bdo*_*lan 5

试试--std = gnu99.

GCC的默认值是'--std = gnu89',这意味着C89具有GNU扩展名.通过选择'--std = c99',您将启用C99,但禁用GNU扩展.'--std = gnu99'将选择C99和GNU扩展支持,为您提供两全其美的优势.

  • 或者使用`-std = c99 -D_GNU_SOURCE` (2认同)