2014-10-08 53 views
1

我会很感激与下一个C结构转换为德尔福如何C结构转换与工会内部德尔福

struct MATRIX 
{ 
    union 
    { 
     struct 
     { 
     float _11, _12, _13, _14; 
     float _21, _22, _23, _24; 
     float _31, _32, _33, _34; 
     float _41, _42, _43, _44; 
     }; 
     float m[4][4]; 
    }; 
}; 

我读过鲁迪的文章有关转换http://rvelthuis.de/articles/articles-convert.html任何帮助,但还是无法弄清楚如何处理联合中的匿名结构..

感谢您的任何帮助或建议。

+0

在这种情况下,你是幸运的,没有必要担心匿名联合德尔福失踪。所有变体成员都在struct结尾,所以翻译非常简单。 – 2014-10-08 21:59:02

+0

我明白了,谢谢! – anikoy 2014-10-08 22:28:27

+0

只是FWIW,我在这里解释一下:[转换的陷阱](http://rvelthuis.de/articles/articles-convert.html#unions)。 – 2014-10-10 09:24:35

回答

4

使用variant record

type 
    Matrix = record 
    case boolean of 
    false: (_11,_12,_13,_14, 
      _21,_22,_23,_24, 
      _31,_32,_33,_34, 
      _41,_42,_43,_44: Single); 
    true: (m: array[0..3,0..3] of Single); 
    end; 
+0

'float'是单精度的,除非特别重新定义。 – 2014-10-08 21:42:56

+0

这很简单..谢谢! – anikoy 2014-10-08 22:29:17