internal / external include files

Greg KH greg at kroah.com
Wed Jul 24 05:21:33 EDT 2019


On Wed, Jul 24, 2019 at 11:11:00AM +0200, Martin Kaiser wrote:
> Dear all,
> 
> is it correct that the files under include/uapi/ can be included by a
> user space application?

Yes.

> I just ran into an error where my application ended up including
> include/uapi/linux/stddef.h (with a number of intermediate steps).

That's odd, what did you ask to be included that caused that?

> This fails because the kernel's stddef.h includes
> include/linux/compiler_types.h and this file is internal to
> the kernel.

What kernel version did this happen for?

> What is the correct way to solve this? Should I fix my include path to
> make sure that my application picks the stddef.h in the compiler's
> sysroot rather than the kernel's stddef.h?

The system stddef.h should always be used "first".

> Or should include/uapi/linux/stddef.h guard the kernel-internal parts
> using #ifdef __KERNEL__?

There should no longer be any need for that.

thanks,

greg k-h



More information about the Kernelnewbies mailing list