lkml.org 
[lkml]   [2011]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [Q] compiler no longer warning about undeclared struct?
From
Date
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



\
 
 \ /
  Last update: 2011-07-28 12:45    [W:2.080 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site