vector unsigned int v1;
vector unsigned int v2 = (vector unsigned int)(10);
v1 = v2;
The AltiVec specification allows a vector type to be initialized by an initializer list. This feature is an extension for compatibility with GNU C.
The number of values in a braced initializer list must be less than or equal to the number of elements of the vector type. Any uninitialized element will be initialized to zero.Vector initializer list syntax .- ,----------. V | >>-vector_type----identifier--=--{----initializer-+--}--;------><
vector unsigned int v1 = {1}; // initialize the first 4 bytes of v1 with 1
// and the remaining 12 bytes with zeros
vector unsigned int v2 = {1,2}; // initialize the first 4 bytes of v2 with 1
// and the next 4 bytes with 2
vector unsigned int v3 = {1,2,3,4}; // equivalent to the vector literal
// (vector unsigned int) (1,2,3,4)
Unlike
vector literals, the values in the initializer list do not have to
be constant expressions unless the initialized vector variable has
static duration. Thus, the following code is
legal: int i=1;
int function() { return 2; }
int main()
{
vector unsigned int v1 = {i, function()};
return 0;
}
