Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

After 14 non-maintainer releases, I'm the S-Lang non-maintainer. -- Ray Dassen


devel / comp.lang.c / "incomplete type" question

SubjectAuthor
* "incomplete type" questionstdcerr
+* Re: "incomplete type" questionDavid Brown
|`- Re: "incomplete type" questionstdcerr
`* Re: "incomplete type" questionAndrey Tarasevich
 +- Re: "incomplete type" questionAndrey Tarasevich
 `- Re: "incomplete type" questionAndrey Tarasevich

1
"incomplete type" question

<b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17065&group=comp.lang.c#17065

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9244:: with SMTP id u65mr5205336qkd.46.1624378449461;
Tue, 22 Jun 2021 09:14:09 -0700 (PDT)
X-Received: by 2002:a05:620a:1113:: with SMTP id o19mr5188468qkk.229.1624378449213;
Tue, 22 Jun 2021 09:14:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 22 Jun 2021 09:14:09 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=24.87.40.64; posting-account=ITQB8goAAACqwP7vVe7b-QwIWpcBL1Ll
NNTP-Posting-Host: 24.87.40.64
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
Subject: "incomplete type" question
From: ron.egg...@gmail.com (stdcerr)
Injection-Date: Tue, 22 Jun 2021 16:14:09 +0000
Content-Type: text/plain; charset="UTF-8"
 by: stdcerr - Tue, 22 Jun 2021 16:14 UTC

Hi,

I'm getting a couple of **field 'xyz' has incomplete type** errors and I'm not so sure about why this is and how to resolve it. The particular error in question is:

sockdefs.h:102: error: field 'xId' has incomplete type

where the structure looks like:

typedef struct
{
struct TRANSPORTID xId;
WORD wLength; /* Length of the payload */
OCTET *poPayload;
} UDPPACKET;

where TRANSPORTID is defined as:

typedef struct
{
/*Netergy4Alma */
WORD wSrcIpAddr[2];
WORD wDstIpAddr[2];
E_ADDRTYPE eDstAddrType;
OCTET oIfIdx;
WORD wVlan;
/*Netergy4Alma */
WORD wGatewayAddr[2];
WORD wSecurityPolicy[2];
WORD wIpSecHdrLength;
WORD wIpSecTrailLength;

OCTET aoUnused[20]; /* Adjust the size so that it is as big
* as a NETWORKID */
/*Netergy4Alma */
} TRANSPORT2NETWORKID;

typedef struct
{
WORD wSrcPort;
WORD wDstPort;

TRANSPORT2NETWORKID xNetId;
/*Netergy4Alma */
} TRANSPORTID;

Where `E_ADDRTYPE` is an enum.

why does the compiler report this as an incomplete type?

Re: "incomplete type" question

<sat2ll$vea$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17066&group=comp.lang.c#17066

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: "incomplete type" question
Date: Tue, 22 Jun 2021 18:21:09 +0200
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <sat2ll$vea$1@dont-email.me>
References: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Jun 2021 16:21:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9659c884e299bf740c3aa0fa10e4614d";
logging-data="32202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KAyzPJfbL9yAGiCMzCpMg06OKeGCkzqw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:oqV2alpSNXqLuaPbjIzB+0BmMoE=
In-Reply-To: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Tue, 22 Jun 2021 16:21 UTC

On 22/06/2021 18:14, stdcerr wrote:
> Hi,
>
> I'm getting a couple of **field 'xyz' has incomplete type** errors and I'm not so sure about why this is and how to resolve it. The particular error in question is:
>
> sockdefs.h:102: error: field 'xId' has incomplete type
>
> where the structure looks like:
>
> typedef struct
> {
> struct TRANSPORTID xId;
> WORD wLength; /* Length of the payload */
> OCTET *poPayload;
> } UDPPACKET;
>
> where TRANSPORTID is defined as:
>
> typedef struct
> {
> /*Netergy4Alma */
> WORD wSrcIpAddr[2];
> WORD wDstIpAddr[2];
> E_ADDRTYPE eDstAddrType;
> OCTET oIfIdx;
> WORD wVlan;
> /*Netergy4Alma */
> WORD wGatewayAddr[2];
> WORD wSecurityPolicy[2];
> WORD wIpSecHdrLength;
> WORD wIpSecTrailLength;
>
> OCTET aoUnused[20]; /* Adjust the size so that it is as big
> * as a NETWORKID */
> /*Netergy4Alma */
> } TRANSPORT2NETWORKID;
>
> typedef struct
> {
> WORD wSrcPort;
> WORD wDstPort;
>
> TRANSPORT2NETWORKID xNetId;
> /*Netergy4Alma */
> } TRANSPORTID;
>
> Where `E_ADDRTYPE` is an enum.
>
> why does the compiler report this as an incomplete type?
>
>

Some people like to call a type like this "struct TRANSPORTID", others
like to use a typedef so that the type is just "TRANSPORTID". (Not many
like to use all-caps names for types, but that's another matter entirely.)

Either method works fine. But you have to be consistent. Your
definition of UDPPACKET uses "struct TRANSPORTID", but no such struct
definition exists - what you have is an anonymous struct with a type
name alias "TRANSPORTID".

Your simplest solution is to change your UDP definition to:

typedef struct
{
TRANSPORTID xId;
WORD wLength; /* Length of the payload */
OCTET *poPayload;
} UDPPACKET;

The alternative would be to change your TRANSPORTID definition to:

typedef struct TRANSPORTID
{
WORD wSrcPort;
WORD wDstPort;

TRANSPORT2NETWORKID xNetId;
/*Netergy4Alma */
} TRANSPORTID;

But if you are using the typedefs, then presumably that is because you
don't want to write "struct" when you use the types - thus the first
solution makes most sense.

Re: "incomplete type" question

<dc16d499-c6a6-450a-8a13-a98849fa4e26n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17067&group=comp.lang.c#17067

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9244:: with SMTP id u65mr5391396qkd.46.1624380675894;
Tue, 22 Jun 2021 09:51:15 -0700 (PDT)
X-Received: by 2002:a05:622a:8f:: with SMTP id o15mr4375666qtw.377.1624380675707;
Tue, 22 Jun 2021 09:51:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 22 Jun 2021 09:51:15 -0700 (PDT)
In-Reply-To: <sat2ll$vea$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=24.87.40.64; posting-account=ITQB8goAAACqwP7vVe7b-QwIWpcBL1Ll
NNTP-Posting-Host: 24.87.40.64
References: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com> <sat2ll$vea$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dc16d499-c6a6-450a-8a13-a98849fa4e26n@googlegroups.com>
Subject: Re: "incomplete type" question
From: ron.egg...@gmail.com (stdcerr)
Injection-Date: Tue, 22 Jun 2021 16:51:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: stdcerr - Tue, 22 Jun 2021 16:51 UTC

HI David,

Thanks for your quick response!
> Some people like to call a type like this "struct TRANSPORTID", others
> like to use a typedef so that the type is just "TRANSPORTID". (Not many
> like to use all-caps names for types, but that's another matter entirely.)

Yes, this is all source code I am inheriting, not written by myself but I see very much what you're saying!

> Either method works fine. But you have to be consistent. Your
> definition of UDPPACKET uses "struct TRANSPORTID", but no such struct
> definition exists - what you have is an anonymous struct with a type
> name alias "TRANSPORTID".
>
> Your simplest solution is to change your UDP definition to:
>
> typedef struct
> {
> TRANSPORTID xId;
> WORD wLength; /* Length of the payload */
> OCTET *poPayload;
> } UDPPACKET;

This is what I went with in the end. That's also where I had started but then got the incomplete type error so I added struct in fron of TRANSPORTID only to eventually figure out, that the include that defined the TRANSPORTID type wasn't included. It was odd to me that the compiler would recognize the type but not its size and hence report an incomplete type (rather that unknown). Anyways, I'm past this now and again, thank you for your time!

Re: "incomplete type" question

<sau819$29o$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17068&group=comp.lang.c#17068

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: "incomplete type" question
Date: Tue, 22 Jun 2021 19:58:47 -0700
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <sau819$29o$1@dont-email.me>
References: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Jun 2021 02:58:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="777903db203f47687eed50a0d6531a5a";
logging-data="2360"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QMQ82aWTjz52c6MUvxrX+"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:mwJZiI/q14BG1V4iVc9RqqNFSf4=
In-Reply-To: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
Content-Language: en-US
 by: Andrey Tarasevich - Wed, 23 Jun 2021 02:58 UTC

On 6/22/2021 9:14 AM, stdcerr wrote:
>
> why does the compiler report this as an incomplete type?
>

Because type `struct TRANSPORTID` is not complete at the point where you
attempt to use it. The type is either completely unknown or already
known but still incomplete (forward declared).

In C using `struct WHATEVER` in a declaration is never an error. It is
either a reference to a known type or introduction of a new type. (In
the latter case the new type is obviously introduced as incomplete.)

Incomplete types can only be used in a number of limited ways. You can't
declare a variable or a field of incomplete type. Hence the error.

In fact, the code you presented do far never declares `struct
TRANSPORTID`. No wonder it seen by the compiler as a completely new (and
incomplete) type.

--
Best regards,
Andrey Tarasevich

Re: "incomplete type" question

<sau882$3u7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17069&group=comp.lang.c#17069

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: "incomplete type" question
Date: Tue, 22 Jun 2021 20:02:23 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <sau882$3u7$1@dont-email.me>
References: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
<sau819$29o$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Jun 2021 03:02:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="777903db203f47687eed50a0d6531a5a";
logging-data="4039"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qH51OkIffqiMICCggDGC4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:5XXcxdds1J/E8AgmcbD7H1a7iv8=
In-Reply-To: <sau819$29o$1@dont-email.me>
Content-Language: en-US
 by: Andrey Tarasevich - Wed, 23 Jun 2021 03:02 UTC

On 6/22/2021 7:58 PM, Andrey Tarasevich wrote:
>
> In C using `struct WHATEVER` in a declaration is never an error.
>

A clarification: what I mean is that such reference to a yet-unknown
type is not an error by itself.

Surrounding context might still be "incompatible" with it, as you can
see in your case.

--
Best regards,
Andrey Tarasevich

Re: "incomplete type" question

<sau92k$7ks$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17070&group=comp.lang.c#17070

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: "incomplete type" question
Date: Tue, 22 Jun 2021 20:16:33 -0700
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <sau92k$7ks$1@dont-email.me>
References: <b53eb2c7-802e-4a7a-98e1-6539d00bca27n@googlegroups.com>
<sau819$29o$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Jun 2021 03:16:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="777903db203f47687eed50a0d6531a5a";
logging-data="7836"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VJVgXw2elnUzs97LDp+3+"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:TufPhAmQJfxip1NTaYJG/b8BfIc=
In-Reply-To: <sau819$29o$1@dont-email.me>
Content-Language: en-US
 by: Andrey Tarasevich - Wed, 23 Jun 2021 03:16 UTC

On 6/22/2021 7:58 PM, Andrey Tarasevich wrote:
>
> In fact, the code you presented do far never declares `struct
> TRANSPORTID`. No wonder it seen by the compiler as a completely new (and
> incomplete) type.
>

I'd guess that you are probably expected your

typedef struct
{
WORD wSrcPort;
WORD wDstPort;

TRANSPORT2NETWORKID xNetId;
/*Netergy4Alma */
} TRANSPORTID;

to declare the type in question. It doesn't.

A declaration that looks as follows

typedef struct A { ... } B;

introduces two type names: `struct A` and `B`. Both refer to the same
type (i.e. `B` is an alias for `struct A`).

But this declaration does not introduce `struct B` type. If you use
`struct B` in your code it will be seen as a completely new and
independent undeclared type.

The same thing happens in your case, per my guess. You declared a
tagless struct type which cannot be referred to through `struct
<something>` syntax at all. The only way to refer to your type above is
`TRANSPORTID`. Note: plain `TRANSPORTID`, not `struct TRANSPORTID`.

There is no full-blown declaration for `struct TRANSPORTID` in your
code. Which is why the first mention of `struct TRANSPORTID` is seen by
the compiler as an introduction of a new incomplete type.

--
Best regards,
Andrey Tarasevich

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor