473,244 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

Help w/ "incomplete type" error

kj


Hi. I'm trying to compile some software from source, and I'm
getting an error I can't figure out. The error in question is

key_events.h:38: field `id' has incomplete type

and the lines corresponding to the error are:

struct kb_event_id_s
{
char name[16];
int number;
};
typedef struct kb_event_id_s kb_event_id_t;

struct kb_event_map_s {
char prefix[8];
const kb_event_id_t id[];
};
typedef struct kb_event_map_s kb_event_map_t;
I can't spot the error. Can someone give me a hand?

Thanks!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Nov 15 '05 #1
5 12271
kj <so***@987jk.com.invalid> wrote:
Hi. I'm trying to compile some software from source, and I'm
getting an error I can't figure out. The error in question is

key_events.h:38: field `id' has incomplete type struct kb_event_map_s {
char prefix[8];
const kb_event_id_t id[];
}; I can't spot the error.


The error is precisely what the error message told you: the field called
id, in the struct called kb_event_map_s, has incomplete type. Variable-
length arrays are valid only in C99, and you're probably using a C89
compiler, so you can't do this. You must give id some specific size. If
you need a variable-length array, you can either find a C99 compiler, or
make id a pointer and use malloc().

Richard
Nov 15 '05 #2
kj wrote:
Hi. I'm trying to compile some software from source, and I'm
getting an error I can't figure out. The error in question is

key_events.h:38: field `id' has incomplete type

and the lines corresponding to the error are:

struct kb_event_id_s
{
char name[16];
int number;
};
typedef struct kb_event_id_s kb_event_id_t;

struct kb_event_map_s {
char prefix[8];
const kb_event_id_t id[]; ^^
The error is due to the fact that you have not specified
the number of elements that id can/should hold. The compiler is at a
loss.
Either initialise the kb_event_id_t array with specific
objects or specify some value between [],
that is evaluated to some integer at compile time. Of course there
are VLA's in C99 but the above should be good enough to get started. };
typedef struct kb_event_map_s kb_event_map_t;
I can't spot the error. Can someone give me a hand?

Thanks!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


Nov 15 '05 #3
Me
> key_events.h:38: field `id' has incomplete type

struct kb_event_map_s {
char prefix[8];
const kb_event_id_t id[];
};
I can't spot the error. Can someone give me a hand?


Your compiler doesn't support C99's flexible array members. Some
pre-C99 compilers implemented this as id[0], if that fails you can
always try the "struct hack" trick (not legal but works well in
practice).

Nov 15 '05 #4
On 6 Jul 2005 05:55:17 -0700, "Suman" <sk*****@gmail.com> wrote:
kj wrote: <snip>
key_events.h:38: field `id' has incomplete type <snip> struct kb_event_map_s {
char prefix[8];
const kb_event_id_t id[];

^^
The error is due to the fact that you have not specified
the number of elements that id can/should hold. The compiler is at a
loss.


For a C90 compiler, as others have noted, true.
Either initialise the kb_event_id_t array with specific
objects or specify some value between [],
that is evaluated to some integer at compile time. Of course there
are VLA's in C99 but the above should be good enough to get started.


All three of these are only applicable to a 'top-level' object, not a
field in a struct which is obviously the case here and as the OP's
quoted error message confirms.

- David.Thompson1 at worldnet.att.net
Nov 15 '05 #5


Dave Thompson wrote:
[snip]...
Either initialise the kb_event_id_t array with specific
objects or specify some value between [],
that is evaluated to some integer at compile time. Of course there
are VLA's in C99 but the above should be good enough to get started.


All three of these are only applicable to a 'top-level' object, not a
field in a struct which is obviously the case here and as the OP's
quoted error message confirms.

My mistake.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lou Pecora | last post by:
g++ compiler error question. I have a container C whose constructor takes a class B that is inherited from an abstract class A. So I have the line of code: B binstance; C ...
1
by: sling blade | last post by:
Hi, For some reason asp.net will not let me publish a new Webpage. I am able to create a new page however when I set it as the start page and hit run, I recieve "Could not load type" error...
0
by: hamstak | last post by:
While attempting to perform a build on an .aspx page from within VS 2005 I receive the "Could not load type" error pertaining to the class representing the page. The class is derived from a custom...
3
by: John Sasso | last post by:
In my Yacc .y file I defined: %union { int value; struct Symbol Sym; } The Symbol struct I defined in a header file I #included in the Prologue section of the .y file as:
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
2
by: magyar.laszlo | last post by:
Hi ! I have an activex .net dll in a webpage. This activeX is trying to connect to an LDAP server using System.DirectoryServices. Unfortunatelly it gets always "request for the permission of...
3
by: eros | last post by:
ALTER TABLE public.postcodes ALTER COLUMN machi TYPE varchar(100); Error: ERROR: syntax error at or near "TYPE"; Error while executing the query (State:42601, Native Code: 7) I am using...
2
by: unclefester | last post by:
I have two classes: Test1 and Test2. Test1 has a field of data type Test2, & vice versa. I need some help in avoiding the incomplete type error ("Error: field has incomplete type"). Test1.h ...
5
by: tejesh | last post by:
I am trying to compile the following code int backend_sm_run(struct interface_data *ctx) { xsup_assert((ctx != NULL), "ctx != NULL", TRUE); xsup_assert((ctx->statemachine != NULL),...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.