sto cercando di inizializzare il seguente array sindacato dichiarazione:inizializzare un array di sindacato dichiarazione
typedef union { __m128d m; float f[4]; } mat;
mat m[2] = { {{30467.14153,5910.1427,15846.23837,7271.22705},
{30467.14153,5910.1427,15846.23837,7271.22705}}};
Ma I'getting il seguente errore:
matrix.c: In function ‘main’:
matrix.c:21: error: incompatible types in initialization
matrix.c:21: warning: excess elements in union initializer
matrix.c:21: warning: (near initialization for ‘m[0]’)
matrix.c:21: warning: excess elements in union initializer
matrix.c:21: warning: (near initialization for ‘m[0]’)
matrix.c:21: warning: excess elements in union initializer
matrix.c:21: warning: (near initialization for ‘m[0]’)
matrix.c:21: error: incompatible types in initialization
matrix.c:21: warning: excess elements in union initializer
matrix.c:21: warning: (near initialization for ‘m[1]’)
matrix.c:21: warning: excess elements in union initializer
matrix.c:21: warning: (near initialization for ‘m[1]’)
matrix.c:21: warning: excess elements in union initializer
matrix.c:21: warning: (near initialization for ‘m[1]’)
Deve esserci anche un insieme di parentesi graffe attorno all'intera espressione '.f = {...}'. – cdhowie
@cdhowie Grazie, errore di battitura. Fisso. – unwind
La soluzione più pulita stava spostando la dichiarazione float nella prima posizione. Questo rende inutile l'uso di ".f" e si compila senza errori. Grazie. – albertgumi