08-12-2010 08:51 PM
Never seen this before in any C compiler, I've got the following code:
#define NAICHAN 7 #define NAOCHAN 4 #define NPID NAOCHAN typedef struct _AppData AppData; typedef struct _PidData PidData; typedef struct _AiChData AiChData; typedef struct _AoChData AoChData; struct _AppData { int thr_id_plot; int thr_id_log; int thr_id_pid[NPID]; int thr_id_timer; FILE *log; AiChData ai_chans[NAICHAN]; AoChData ao_chans[NAOCHAN]; PidData pid[NPID]; };
and for some reason when I try to compile I get the following error (last line is line 57)
"util.h"(57,1) Structures containing unspecified size array fields must contain other fields and the unspecified size array must be the last field.
It doesn't look to me as though any of the arrays have an unspecified size so I'm a little confused by what the compiler wants.
Thanks in advance for any help.
Solved! Go to Solution.
08-12-2010 11:53 PM
Hi coanda,
I do not know if this is a bug in the compiler or an expected behaviour but I could overcome the problem by rearranging your code as follows:
I inserted dummy struct definitions for AiChData, AoChData and PidData.
You can replace them with their correct definitions.
#define NAICHAN 7 #define NAOCHAN 4 #define NPID NAOCHAN typedef struct _AiChData { int x; }AiChData; typedef struct _PidData { int y; }PidData; typedef struct _AoChData { int z; }AoChData; typedef struct _AppData { int thr_id_plot; int thr_id_log; int thr_id_pid[NPID]; int thr_id_timer; FILE *log; AiChData ai_chans[NAICHAN]; AoChData ao_chans[NAOCHAN]; PidData pid[NPID]; } AppData;
08-13-2010 01:47 PM
Thanks, reordering solved the problem. Strange though that the CVI compiler isn't able to handle this, I've been organizing my code this way for a while now and gcc has never complained.
08-16-2010 01:40 AM
Hi,
I am glad that worked for you.
Every compiler has its own "trend" that somehow you get used to in time.
It will also be nice if you can mark the topic as "solved".
Regards,