Error Array Type Has Incomplete Element Type Struct
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies array type has incomplete element type extern struct of this site About Us Learn more about Stack Overflow the company Business error array type has incomplete element type in c Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask error array type has incomplete element type gcc Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign
Array Type Has Incomplete Element Type C
up C Compile Error: array type has incomplete element type up vote 3 down vote favorite #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more type of formal parameter 1 is incomplete c about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users
Array Has Incomplete Element Type 'char '
Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping
Incomplete Array
each other. Join them; it only takes a minute: Sign up GCC: array type has incomplete element type up vote 14 down vote favorite 4 I have declared a struct, and I try to pass an array of those http://stackoverflow.com/questions/21080744/c-compile-error-array-type-has-incomplete-element-type structs (as well as a double array of doubles, and an integer) into a function. I get an "array type has incomplete element type" message from gcc when I compile it. What have I got wrong in how I pass the struct into the function? typedef struct graph_node { int X; int Y; int active; } g_node; void print_graph(g_node graph_node[], double weight[][], int nodes); I have also tried struct g_node graph_node[], but I get the same thing. http://stackoverflow.com/questions/10003270/gcc-array-type-has-incomplete-element-type c arrays gcc struct share|improve this question asked Apr 4 '12 at 0:15 Josh 94021632 Are you absolutely positive the struct declaration comes before the function prototype? –Platinum Azure Apr 4 '12 at 0:26 add a comment| 2 Answers 2 active oldest votes up vote 17 down vote accepted It's the array that's causing trouble in: void print_graph(g_node graph_node[], double weight[][], int nodes); The second and subsequent dimensions must be given: void print_graph(g_node graph_node[], double weight[][32], int nodes); Or you can just give a pointer to pointer: void print_graph(g_node graph_node[], double **weight, int nodes); However, although they look similar, those are very different internally. If you're using C99, you can use variably-qualified arrays. Quoting an example from the C99 standard (section ยง6.7.5.2 Array Declarators): void fvla(int m, int C[m][m]); // valid: VLA with prototype scope void fvla(int m, int C[m][m]) // valid: adjusted to auto pointer to VLA { typedef int VLA[m][m]; // valid: block scope typedef VLA struct tag { int (*y)[n]; // invalid: y not ordinary identifier int z[n]; // invalid: z not ordinary identifier }; int D[m]; // valid: auto VLA static int E[m]; // invalid: static block scope VLA extern int F[m]; // invalid: F has linkage and is VLA int (*s)[m]; // valid: auto pointer to VLA extern int (*r)[m]; // invalid: r has linkage and points to VLA static int (*q)[
kizeren Member Registered: 2006-10-20 Posts: 5 array type has incomplete element type [solved] Well, not quite sure where to ask this question. I have tried some MUD sites. All give two options for fixing the problem with this error. Neither which seem to work.First https://bbs.archlinux.org/viewtopic.php?id=26210 one is, extern const struct flag_type *act_flags; struct flag_type { ... };Second is,struct flag_type { https://gcc.gnu.org/ml/gcc/2005-02/msg00053.html ... }; extern const struct flag_type act_flags[];I have tried both these and still does not comiple.Now after searching for couple of hours on posts and the web, I found that this is the proper way for array declarations?extern const struct flag_type *mprog_flags;So now I have the correct syntax above and for the actual array I have:const struct flag_type mprog_flags[] = { has incomplete { "act", TRIG_ACT, TRUE }, { "bribe", TRIG_BRIBE, TRUE }, { "death", TRIG_DEATH, TRUE }, { "entry", TRIG_ENTRY, TRUE }, { "fight", TRIG_FIGHT, TRUE }, { "give", TRIG_GIVE, TRUE }, { "greet", TRIG_GREET, TRUE }, { "grall", TRIG_GRALL, TRUE }, { "kill", TRIG_KILL, TRUE }, { "hpcnt", TRIG_HPCNT, TRUE }, { "random", TRIG_RANDOM, TRUE }, { "speech", TRIG_SPEECH, TRUE }, { "exit", TRIG_EXIT, TRUE }, { "exall", TRIG_EXALL, TRUE }, { "delay", TRIG_DELAY, TRUE }, { has incomplete element "surr", TRIG_SURR, TRUE }, { NULL, 0, TRUE } };Since I have been told this is still the proper way to do the array itself.But again when I compile I get more errors like below.tables.c:493: error: conflicting types for 'mprog_flags' tables.h:96: error: previous declaration of 'mprog_flags' was here tables.c:542: error: conflicting types for 'exit_flags' tables.h:95: error: previous declaration of 'exit_flags' was here tables.c:569: error: conflicting types for 'room_flags' tables.h:93: error: previous declaration of 'room_flags' was hereNow is my problem that I have the array declaration in seperate file as the actual array? Or am I just completly missing it?I am using GCC Version 4.1.1.Thanks in advance for anyone who may know the answer and who take the time to read this post.I will be more then happy to share the code if anyone would be interested in helping me. Offline #2 2006-10-20 05:13:13 tardo Member Registered: 2006-07-15 Posts: 526 Re: array type has incomplete element type [solved] extern const struct flag_type *mprog_flags; I think that the only time you'd use extern is when accessing a function/variable in another file.const struct flag_type mprog_flags[] = { { "act", TRIG_ACT, TRUE }, { "bribe", TRIG_BRIBE, TRUE }, { "death", TRIG_DEATH, TRUE }, .... }I believe this only works if you have a multi-dimensional array, in which case you don't.I think what you're trying to do isconst struct flag_type mprog_flags[17]; mprog_flags[0].var
array type has incomplete element type From: Ralf Corsepius