kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Kernel header inclusion practice
@ 2017-07-05  6:50 Shiyao MA
  2017-07-05 12:07 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Shiyao MA @ 2017-07-05  6:50 UTC (permalink / raw)
  To: kernelnewbies

Hi,

How do you include the kernel headers?

For example,
Currently I have the headers:
#include <linux/module.h>
#include <linux/kthread.h>
#include <linux/delay.h>

And now I wanna use the  `struct workqueue_struct'. It turns out I
don't have to include the "linux/workqueue.h".

So it must have already been included by the three headers above.

My question is:

What's the practice of including headers?
Should I specifically include "linux/workqueue.h" ?


Another question is particular to the above three headers: does any of
them guarantee to include the "linux/queue.h"?

If there is any documentation about the API of the headers (e.g., what
they include), that will be great.


Best

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Kernel header inclusion practice
  2017-07-05  6:50 Kernel header inclusion practice Shiyao MA
@ 2017-07-05 12:07 ` Greg KH
  2017-07-05 12:13   ` Shiyao Ma
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2017-07-05 12:07 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Jul 05, 2017 at 02:50:59PM +0800, Shiyao MA wrote:
> Hi,
> 
> How do you include the kernel headers?
> 
> For example,
> Currently I have the headers:
> #include <linux/module.h>
> #include <linux/kthread.h>
> #include <linux/delay.h>
> 
> And now I wanna use the  `struct workqueue_struct'. It turns out I
> don't have to include the "linux/workqueue.h".
> 
> So it must have already been included by the three headers above.
> 
> My question is:
> 
> What's the practice of including headers?
> Should I specifically include "linux/workqueue.h" ?

To be safe, yes, please do, sometimes other arches will not pull in the
.h files automatically that you expect them to.  So be specific.

> Another question is particular to the above three headers: does any of
> them guarantee to include the "linux/queue.h"?

Nope, if you need it, list it.

> If there is any documentation about the API of the headers (e.g., what
> they include), that will be great.

What exactly do you mean by this?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Kernel header inclusion practice
  2017-07-05 12:07 ` Greg KH
@ 2017-07-05 12:13   ` Shiyao Ma
  2017-07-05 12:32     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Shiyao Ma @ 2017-07-05 12:13 UTC (permalink / raw)
  To: kernelnewbies

Thanks!

> On 5 Jul 2017, at 20:07, Greg KH <greg@kroah.com> wrote:
> 
>> 
>> If there is any documentation about the API of the headers (e.g., what
>> they include), that will be great.
> 
> What exactly do you mean by this?


I mean if any kernel documentation specifies what the headers provide, IOW, what they include, and what functions/variables they declare.

So I guess probably not, the source code of kernel headers are their own documentation/specification.

Best,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Kernel header inclusion practice
  2017-07-05 12:13   ` Shiyao Ma
@ 2017-07-05 12:32     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2017-07-05 12:32 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Jul 05, 2017 at 08:13:08PM +0800, Shiyao Ma wrote:
> Thanks!
> 
> > On 5 Jul 2017, at 20:07, Greg KH <greg@kroah.com> wrote:
> > 
> >> 
> >> If there is any documentation about the API of the headers (e.g., what
> >> they include), that will be great.
> > 
> > What exactly do you mean by this?
> 
> 
> I mean if any kernel documentation specifies what the headers provide,
> IOW, what they include, and what functions/variables they declare.
> 
> So I guess probably not, the source code of kernel headers are their
> own documentation/specification.

Yes, the source itself is always the best documentation, it's always
kept up to date :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-05 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-05  6:50 Kernel header inclusion practice Shiyao MA
2017-07-05 12:07 ` Greg KH
2017-07-05 12:13   ` Shiyao Ma
2017-07-05 12:32     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).