Re: internal / external include files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thus wrote Greg KH (greg@xxxxxxxxx):

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

I called gcc with -I $KERNEL_ROOT/include/uapi. This is the chain of
files that were included.

my_app.c
   $GCC_SYSROOT/usr/include/netinet/in.h
      $GCC_SYSROOT/usr/include/sys/socket.h
         $KERNEL_ROOT/include/uapi/asm-generic/socket.h
            $KERNEL_ROOT/include/uapi/linux/posix_types.h
               $KERNEL_ROOT/include/uapi/linux/stddef.h


and the error is

$KERNEL_ROOT/include/uapi/linux/stddef.h:2:34: fatal error:
linux/compiler_types.h: No such file or directory
#include <linux/compiler_types.h>

> > 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?

I get the error with today's linux-next tree. 4.14 is fine.

> > 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".

My understanding of the gcc manual is that directories specified with -I
are searched before the system directories.

https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Directory-Options.html#Directory-Options

So it seems that -I /my/kernel/include/uapi is not a good idea since the
kernel's include files take precedence then.

Best regards,
Martin

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux