0

Is there a Linux Kernel #ifdef directive for conditional compilation available, which is set by the kernel build system (kbuild)?

Usecase:

I have a source code file with register map entries for a SoC and with functions used by a Kernel driver. This file shall be includable by userspace programs as well to use the register map entries:

myheader.h:

...
#define REGENTRY1   0x0001
#define REGENTRY2   0x0002
.....
#ifdef ANY_KERNEL_DIRECTIVE???
   firstkernelspacefunc();
   ....
#endif

Or maybe there are other solutions to this usecase?

bambino307
  • 493
  • 2
  • 4
  • 13
  • For me, `__KERNEL__` of [this](https://stackoverflow.com/questions/4744758/what-is-kernel-used-for-in-linux-kernel) post solved this problem – bambino307 Jul 11 '19 at 11:49
  • There is a split inside the kernel, UAPI headers are specifically provided for user space programs that communicate with kernel. – 0andriy Jul 12 '19 at 10:36

0 Answers0