我有一个像这样的结构的typedef
typedef struct { double x, y; } ACVector;
当我在调试器中查看此实例时,我会得到非常奇怪的输出,例如
(lldb) p _translation
(ACVector) $1 = {
(double) x = -5503.61
(double) y = -5503.61
(CLLocationDegrees) latitude = -5503.61
(CLLocationDegrees) longitude = -1315.67
}
(lldb) p _translation.x
(double) $2 = -5503.61
(lldb) p _translation.y
(double) $2 = -5503.61
如果我将 ACVector 的定义更改为
typedef struct ACVector { double x, y; } ACVector;
并在调试器中做同样的事情我得到了我所期望的
(lldb) p _translation
(ACVector) $1 = {
(double) x = -5503.61
(double) y = -1315.67
}
对 typedef 使用匿名结构是合法的
好的,所以更多的代码
_translation 的声明是作为一个实例变量
ACVector _translation;
我使用这个函数来初始化变量
ACVector ACVectorMake( double x, double y )
{
ACVector r;
r.x = x;
r.y = y;
return r;
}
像这样
_translation = ACVectorMake( d[xp[0]].x-s[xp[0]].x, d[xp[0]].y-s[xp[0]].y );
原本是一个
ACVector ACVectorMake( double x, double y )
{
return (ACVector){x,y};
}
以及调试器输出中的纬度和经度元素来自哪里,请注意您无法单独访问它们
响应在其他地方定义的 ACVector 的更多信息
我有两个定义
#define ACVectorZero (ACVector){(double)0.0,(double)0.0}
#define ACVectorUnit (ACVector){(double)1.0,(double)1.0}
有趣的是,紧随其后的是
#define ACDegreesFromDegreesMinutesSeconds( d, m, s ) (CLLocationDegrees)(d+m/60.0+s/3600.0)
#define ACLocationFromDegreesMinutesSeconds( yd, ym, ys, xd, xm, xs ) (CLLocationCoordinate2D){ACDegreesFromDegreesMinutesSeconds( xd, xm, xs ), ACDegreesFromDegreesMinutesSeconds( yd, ym, ys )}
这可以解释也许可以解释 ACVector 中纬度和经度的出现
是否搜索了 ACVector 的每次出现,包括在库中,找不到任何其他出现的 ACVector 正在定义