【发布时间】:2016-03-04 15:34:27
【问题描述】:
我正在尝试快速实现以下代码。但我的i 变量拒绝与我的 MAXADDRS 对话。它在 Swift 中显示 binary operator < cannot be applied to Clong。如果我使用CInt,问题就会消失,但是当assiginin theAddr = ip_addrs[i] 时,变量i 会出现错误
InitAddresses();
GetIPAddresses();
GetHWAddresses();
var i = CLong()
var deviceIP = NSString()
for (i=0; i < MAXADDRS; ++i)
{
var localHost = 0x7F000001; // 127.0.0.1
var theAddr = CLong()
theAddr = ip_addrs[i]
if (theAddr == 0) {return}
if (theAddr == localHost){continue}
NSLog("Name: %s MAC: %s IP: %s\n", if_names[i], hw_addrs[i], ip_names[i]);
//decided what adapter you want details for
if (strncmp(if_names[i], "en", 2) == 0)
{
NSLog("Adapter en has a IP of %s", ip_names[i]);
}
}
// Do any additional setup after loading the view, typically from a nib.
}
它打算比较的 MAXADDRS 与以下 OBC 标头有关
这里是源文件
http://www.chrisandtennille.com/code/IPAddress.h http://www.chrisandtennille.com/code/IPAddress.c
我的桥接头
#include "IPAddress.h"
#include "IPAddress.c"
【问题讨论】:
-
CLong是Int(“C long 类型”)的(预定义)别名。 -
MAXADDRS 在哪里/如何定义?
-
@MartinR 谢谢 - Google 在我的研究中返回非常。
-
我已经用 MAXADDRS 更新了这个问题。我热衷于使用 Int 而不是 CLong。但后来我得到了不同的错误。
标签: swift