mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [Q] compiler no longer warning about undeclared struct?
Date: Thu, 28 Jul 2011 12:03:27 +0200	[thread overview]
Message-ID: <1311847409.3897.23.camel@thorin> (raw)
In-Reply-To: <Pine.LNX.4.64.1107271947490.7435@axis700.grange>

Hi!

On Mit, 2011-07-27 at 19:57 +0200, Guennadi Liakhovetski wrote:
[....]
> I just ran across a driver in the kernel (drivers/media/video/ov2640.c, 
> struct ov2640_priv::info), that does something like
> 
> struct xx {
> 	struct yy *y;
> };
> 
> static void z(void)
> {
> 	struct xx *x;
> 	void *p;
> 
> 	x = ...;
> 	p = ...;
> 	x->y = p;
> }
> 
> where "struct yy" is nowhere declared, and the compiler happily swallows 
> this... Shouldn't it complain? Didn't it complain before?

It's normal C behaviour: As long as the compiler doesn't need the size
or fields of struct yy, it doesn't complain that it doesn't know the
details.

Otherwise you could not define recursive structures as in
----  snip  ----
struct a {
	struct *b;
};
struct b {
	struct *a;
};
----  snip  ----

Kind regards,
	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at


  reply	other threads:[~2011-07-28 10:43 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 [this message]
2011-07-28 10:16   ` Guennadi Liakhovetski
2011-07-28 11:08     ` Andreas Schwab

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=1311847409.3897.23.camel@thorin \
    --to=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®