# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

##### 38.15.1.1. Userland objects vs header-only

When factoring out functionality across userland examples, there are two main options:

- use header-only implementations

- use separate C files and link to separate objects.

The downsides of the header-only implementation are:

- slower compilation time, especially for C++

- cannot call C implementations from assembly files

The advantages of header-only implementations are:

- easier to use, just `#include` and you are done, no need to modify build metadata.

As a result, we are currently using the following rule:

- if something is only going to be used from C and not assembly, define it in a header which is easier to use

  The slower compilation should be OK as long as split functionality amongst different headers and only include the required ones.

  Also we don’t have a choice in the case of C++ template, which must stay in headers.

- if the functionality will be called from assembly, then we don’t have a choice, and must add it to a separate source file and link against it.