QUERY: Inclusion of header files in kernel header files.
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Feb 24 07:59:53 EST 2010
Hi Viresh,
On Wednesday 24 February 2010 05:20:59 viresh kumar wrote:
> > My understanding is that if you are going to include every dependency
> > into the header files, they are going to explode very soon. E.g. like
> > bus.h, as long as you declared something like:
> >
> > struct device;
> > struct resource;
>
> If these two structure prototypes are already present in latest kernel
> then its okay.
> Actually i have seen 2.6.32 and these prototypes are not present
> there, so we may need to add header file or add prototypes of these
> structures.
As a rule of thumb, header files should use forward-declaration of structures
whenever possible. Including other header files to pull in structure
definitions is only required when embedding a structure into another (as the
compiler needs to known the embedded structure size) and when inline functions
or macros dereference pointers to the structure (although in the case of
macros there's not strict requirement).
Exceptions to this rule are of course permitted.
--
Regards,
Laurent Pinchart
More information about the linux-arm-kernel
mailing list