9

I can initialize float32x4_t like this:

const float32x4x4_t zero = { 0.0f, 0.0f, 0.0f, 0.0f };

But this code makes an error Incompatible types in initializer:

const float32x4x4_t one =
{
    1.0f, 1.0f, 1.0f, 1.0f,
    1.0f, 1.0f, 1.0f, 1.0f,
    1.0f, 1.0f, 1.0f, 1.0f,
    1.0f, 1.0f, 1.0f, 1.0f,
};

float32x4x4_t is 4x4 matrix built as:

typedef struct float32x4x4_t
{
    float32x4_t val[4];
}
float32x4x4_t;

How can I initialize this const struct?

eonil
  • 83,476
  • 81
  • 317
  • 516

1 Answers1

12
const float32x4x4_t nameOfVariableHere =
{{
    {1.0f, 1.0f, 1.0f, 1.0f},
    {1.0f, 1.0f, 1.0f, 1.0f},
    {1.0f, 1.0f, 1.0f, 1.0f},
    {1.0f, 1.0f, 1.0f, 1.0f}
}};

The 1st level of parenthesis is for the struct.
The 2nd level is for the array of float32x4_t.
The 3rd level is for float32x4_t itself.

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • Oh my God! I omitted variable name! Sorry for this. I updated my question. And this way makes "error: incompatible types in initialization", "error: extra brace group at end of initializer". Thanks. – eonil May 01 '10 at 12:26
  • @Eonil: Sorry, I've left the extra comma at the end. Try the update. – kennytm May 01 '10 at 13:00
  • Thanks, but removing last comma is not effective. Same errors. – eonil May 01 '10 at 13:04
  • Hi, I'm trying to initialize a uint16x8_t neon vector. By following your answer I have the following code : uint16x8_t myvect = {{0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}}; but GCC complains with this style of vector initialization. In addition, this document http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053a/IHI0053A_acle.pdf says that static construction is not defined (12.2.2) ... – Kami Jul 02 '12 at 08:38