ympolo
ympolo

Reputation: 1

Compilation error using AltiVec SIMD vector type in C++

Following is the code:

int add = foo;
vector signed int v_add;
v_add[0] = add;

The error is: error: invalid types 'vector int[int]' for array subscript

Problem stays when I try add = v_add[0];

Please explain the cause of this problem. I am using gnu version 3.3.2

Upvotes: 0

Views: 257

Answers (2)

ThinkOpenly
ThinkOpenly

Reputation: 156

Works for me:

$ cat vec.cpp
#include <altivec.h>
void foo () {
  int add = 1;
  vector signed int v_add;
  v_add[0] = add;
}
$ g++ -c vec.cpp
$ g++ --version
g++ (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)

Upvotes: 3

Paul R
Paul R

Reputation: 212969

You can't treat AltiVec types like vector signed int as if they are arrays. Use e.g. the vec_ld intrinsic to load values from an array to an AltiVec vector.

Upvotes: 1

Related Questions