array has incomplete element type

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

array has incomplete element type

Nathan Ridge via cfe-dev
Hello, List,

I'm using CLANG (6.0) to analyze C-Code that is written for a Windriver
Compiler.
Given the following piece of code.

extern const struct STRUCT Array[];

typedef struct STRUCT {
        int Member;
} STRUCT;


int Foo (int i) {
        return Array[i].Member;
}

The Windriver compiler compiles this code without any problem (Does the
Windriver compiler violate an ANSI rule?). Buy when compiling which
clang it get
[error: array has incomplete element type 'const struct STRUCT']

(When compiling with clang++ the error goes away)

So my question is. Is there an option to handle the extern array in C
like in C++.


Frank
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: array has incomplete element type

Nathan Ridge via cfe-dev
Hi Frank,

Your question would be more appropriate on the cfe-users mailing list.

Have you tried moving the declaration of struct STRUCT STRUCT ( :) )
in of the declaration of frontArray[] ?

Csaba

On Mon, Jun 17, 2019 at 2:03 PM Frank Redeker via cfe-dev
<[hidden email]> wrote:

>
> Hello, List,
>
> I'm using CLANG (6.0) to analyze C-Code that is written for a Windriver
> Compiler.
> Given the following piece of code.
>
> extern const struct STRUCT Array[];
>
> typedef struct STRUCT {
>         int     Member;
> } STRUCT;
>
>
> int Foo (int i) {
>         return Array[i].Member;
> }
>
> The Windriver compiler compiles this code without any problem (Does the
> Windriver compiler violate an ANSI rule?). Buy when compiling which
> clang it get
> [error: array has incomplete element type 'const struct STRUCT']
>
> (When compiling with clang++ the error goes away)
>
> So my question is. Is there an option to handle the extern array in C
> like in C++.
>
>
> Frank
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



--
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformat way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev