Re: Help w/ "incomplete type" error



kj <socyl@xxxxxxxxxxxxxxxxx> 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
.



Relevant Pages

  • Re: problem with free.
    ... > int main ... You mix statements and declarations in your main program. ... using a C99 compiler, but it's more likely you're using a C++ compiler ...
    (comp.lang.c)
  • Re: Seg faults in merge and quick sort
    ... -The number of elements in an array definition ... unless using a C99 compiler. ... some nonstandard feature of your compiler. ... with type 'size_t', not 'int'. ...
    (comp.lang.c)
  • Compiling with another compiler than gcc.
    ... I have setup a mailing list about pcc, ... After having that project on the shelf for a year or so, I decided to make the compiler ... It is also quite simple to port, writing the basics for i386 took three hours ... I have added most of the C99 stuff (it is supposed to be a c99 compiler) but some stuff ...
    (freebsd-current)
  • Re: Bootstraping compilers ?
    ... For this reason many Gcc compilers may not be able to ... (Assuming host and target are the same). ... However once you have written a C99 compiler you can then ...
    (comp.compilers)
  • Re: How to store a 13 digit number in c ?
    ... multi-precision package (unless you have a C90 compiler that doesn't ... provide a 64-bit integer type, either as an extension or as "long"). ... When did compiler extensions become on-topic and "long" able to hold a ... Almost nobody uses a C99 compiler these days. ...
    (comp.lang.c)