Array Type Has Incomplete Element Type Error
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 of this site About Us Learn more about Stack Overflow the company Business Learn more about error array type has incomplete element type in c 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
Error Label At End Of Compound Statement
them; it only takes a minute: Sign up GCC: array type has incomplete element type up vote 13 down vote favorite 3 I have declared a struct, and I try to pass an array of those structs (as well
Error Array Type Has Incomplete Element Type Mud
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. c arrays gcc struct error expected specifier qualifier list before share|improve this question asked Apr 4 '12 at 0:15 Josh 93021632 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 16 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)[m] = &B; // valid: q is a static bloc
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 error array type has incomplete element type struct About Us Learn more about Stack Overflow the company Business Learn more array type has incomplete element type extern struct about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss array has incomplete element type 'char ' 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 up C error: array http://stackoverflow.com/questions/10003270/gcc-array-type-has-incomplete-element-type type has incomplete element type up vote 3 down vote favorite 1 I'm trying to compile a program in Ubuntu 11.04 that works well in Windows but it gives the above error. I have added a comment to the line that is causing the error. Here's the code: route_input() { int num_routes;//Variable to act as the loop counter for the loop getting route details int http://stackoverflow.com/questions/10395054/c-error-array-type-has-incomplete-element-type x; char route_id[3]; char r_source[20]; char r_destination[20]; int r_buses; printf("Please enter the number of routes used: \n"); scanf("%d", &num_routes); char routes_arr[num_routes][10];//An array to hold the details of each route printf("\nNumber of routes is %d\n", num_routes); struct route r[num_routes];//An array of structures of type route (This line causes the error) fflush(stdin); for (x = num_routes; x > 0; x--) { printf("\nEnter the route number: "); scanf("%s", r[x].route_num); printf("Route number is %s", r[x].route_num); printf("\nEnter the route source: "); fflush(stdin); scanf("%s", r[x].source); printf("Source = %s", r[x].source); printf("\nEnter the route destination: "); fflush(stdin); gets(r[x].destination); printf("Destination = %s", r[x].destination); printf("\nEnter the number of buses that use this route: "); scanf("%d", &r[x].num_of_buses); printf("Number of buses = %d", r[x].num_of_buses); } for (x = num_routes; x > 0; x--) { printf("\n\n+++Routes' Details+++\nRoute number = %s, Source = %s, Destination = %s, Number of buses for this route = %d\n", r[x].route_num, r[x].source, r[x].destination, r[x].num_of_buses); } } c gcc ubuntu struct share|improve this question edited May 1 '12 at 7:56 Nick 13k52967 asked May 1 '12 at 7:55 diamondtrust66 60110 8 Do not fflush(stdin), it is undefined behavior. –ouah May 1 '12 at 7:57 possible duplicate of stackoverflow.com/questions/2274550/… –d
kizeren Member Registered: 2006-10-20 Posts: 5 array type has incomplete element type [solved] Well, not quite sure where to ask https://bbs.archlinux.org/viewtopic.php?id=26210 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 one is, extern const struct flag_type *act_flags; struct flag_type { ... };Second is,struct flag_type { ... }; extern const struct flag_type act_flags[];I have tried both these and still has incomplete 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[] = { { "act", TRIG_ACT, TRUE }, has incomplete element { "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 }, { "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 a