MAC网络ping源$ C ​​$ C编译错误 [英] Mac network ping source code compile error

查看:243
本文介绍了MAC网络ping源$ C ​​$ C编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从苹果网站下载的Mac OS网络ping源$ C ​​$ C:的http://www.opensource.apple.com/tarballs/network_cmds/network_cmds-356.8.tar.gz

I download the Mac OS network ping source code from Apple: http://www.opensource.apple.com/tarballs/network_cmds/network_cmds-356.8.tar.gz

和编译它在X code,但得到两个10.7和10.6的错误,

and compile it in xcode, but get errors in both 10.7 and 10.6,

IP_NO_IFT_CELLULAR'未申报(在一次使用此功能)结果
  SO_TRAFFIC_CLASS'未申报(在一次使用此功能)结果
  SO_RECV_TRAFFIC_CLASS'未申报(在一次使用此功能)结果
  SO_TRAFFIC_CLASS'未申报(在一次使用此功能)

'IP_NO_IFT_CELLULAR' undeclared (first use in this function)
'SO_TRAFFIC_CLASS' undeclared (first use in this function)
'SO_RECV_TRAFFIC_CLASS' undeclared (first use in this function)
'SO_TRAFFIC_CLASS' undeclared (first use in this function)

我错过了什么?

推荐答案

我认为这是可能的,你需要导入网络框架到您的项目,但苹果并没有提供有关您的项目中的任何说明或信息下载。

I thought it was possible that you needed to import a networking framework into your project, but Apple doesn't provide any description or information about the project you've downloaded.

有关子孙后代的缘故:
要添加框架,选择左上角的项目,然后点击你的目标,挑选从结果页面顶部的构建阶段,链接二进制与图书馆','+'。

For posterity's sake: To add frameworks, select the project in the top left, then click your target, pick 'Build Phases' from the top of the resulting page, 'Link Binary With Libraries', '+'.

我终于加入以下的ping.c文件(一个与错误标记​​),以得到它的详尽的谷歌搜索后建:

I finally managed to get it to build after exhaustive googling by adding the following to the ping.c file (the one flagged with the errors):

#define IP_NO_IFT_CELLULAR  6969 /* for internal use only */
#define IP_NO_IFT_PDP       IP_NO_IFT_CELLULAR /* deprecated */
#define SO_TRAFFIC_CLASS        0x1086      /* Traffic class (int)*/
#define SO_RECV_TRAFFIC_CLASS   0x1087      /* Receive traffic class (bool)*/

这可笑从谷歌收录了其他开源项目的苹果来了。

Which amusingly came from other open source Apple projects that Google had indexed.

这篇关于MAC网络ping源$ C ​​$ C编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆