mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@redhat.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at>,
	linux-kernel@vger.kernel.org
Subject: Re: [Q] compiler no longer warning about undeclared struct?
Date: Thu, 28 Jul 2011 13:08:53 +0200	[thread overview]
Message-ID: <m3ipqmek6y.fsf@hase.home> (raw)
In-Reply-To: <Pine.LNX.4.64.1107281211120.20737@axis700.grange> (Guennadi Liakhovetski's message of "Thu, 28 Jul 2011 12:16:04 +0200 (CEST)")

Guennadi Liakhovetski <g.liakhovetski@gmx.de> writes:

> I always thought you need forward declarations for those, as in
>
> struct yy;
>
> before declaring struct xx above.

You only need that if you would otherwise introduce the struct tag in a
different scope, like prototype scope (which ends at the end of the
prototype).

>> Otherwise you could not define recursive structures as in
>> ----  snip  ----
>> struct a {
>> 	struct *b;
>> };
>> struct b {
>> 	struct *a;
>> };
>> ----  snip  ----
>
> I would add a "struct b;" forward declaration before "struct a".

You can do that, but since a struct definition doesn't introduce a new
scope it is not necessary.

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

      reply	other threads:[~2011-07-28 11:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 17:57 Guennadi Liakhovetski
2011-07-28 10:03 ` Bernd Petrovitsch
2011-07-28 10:16   ` Guennadi Liakhovetski
2011-07-28 11:08     ` Andreas Schwab [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ipqmek6y.fsf@hase.home \
    --to=schwab@redhat.com \
    --cc=bernd@petrovitsch.priv.at \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®