加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 解析成员的请求…这是非类型的

发布时间:2020-12-16 07:11:33 所属栏目:百科 来源:网络整理
导读:我想知道为什么以下代码在Visual Studio中编译但在移植期间在Mingw GCC中出现编译错误.这是我第一次接触__m128类型,但从 this链接到此处说明 You should not access the __m128 fields directly. You can,however,see these types in the debugger. A variab
我想知道为什么以下代码在Visual Studio中编译但在移植期间在Mingw GCC中出现编译错误.这是我第一次接触__m128类型,但从 this链接到此处说明

You should not access the __m128 fields directly. You can,however,see these types in the debugger. A variable of type __m128 maps to the XMM[0-7] registers.

代码库非常旧,这种类型被用作

Matrix m;
__m128  b0 = _mm_set_ps(b[0][0],b[1][0],b[2][0],0);
__m128  b1 = _mm_set_ps(b[0][2],b[1][3],b[2][4],0);

__m128  a00 = _mm_load1_ps(&a[0][0]);
__m128  a10 = _mm_load1_ps(&a[1][0]);
__m128  r1a = _mm_mul_ps(a00,b0);
__m128  r1b = _mm_mul_ps(a10,b1);
__m128  r1 = _mm_add_ps(r1a,r1b);

m[0][0] = r1.m128_f32[3];

我得到的错误是

error: request for member 'm128_f32' in 'r1',which is of non-class type '__m128 {aka __vector(4) float}'
  m[0][0] = r1.m128_f32[3];

我试着查找这个错误here和here然而我相信他们不适用于我的情况,因为他们处理C最烦恼的解析问题.
有关如何解决此问题的任何建议将不胜感激.谢谢.

解决方法

GCC不像VS那样对这些类型使用union,类型作为内置类型处理.您可以直接索引__m128,参见 here. 当然,这引入了可移植性问题.在我的项目中,我使用带有union和重载operator []的包装类,但生成的代码是次优的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读