Drivers should always use the compiler, linker, and other tools that come from the same operating system release as the kernel and which were used to build the rest of the kernel. Other compilers can be used for compiling user-level applications on systems but should not be used for compiling drivers. Different compilers use different bitfield conventions and structure layouts; see ``Bitfields''. This can cause problems in kernel code, because the entire kernel is linked together as a single executable binary. This also means that it is not possible to create universal device driver binaries.
Note that kernel-level drivers must never call user-level libraries, so no -l options can be used on the compile line.
The sample drivers that are included on the HDK CD-ROM or the HDK homepage include sample Makefiles that can be studied for more details about compiling drivers.
This article covers the following topics:
The following command options are required when compiling DDI drivers:
Alternately, the source code can include the following lines, before any header files are #included:
#define _KERNEL #define _DDI 8The _DDI option or line gives the ``major'' version number, such as 7 or 8; it does not use full version numbers such as 8.1 or 8mp.
The following command options are used when compiling ODDI drivers:
Note that the idcomp compiler that is used to compile driver's space.c files is not an ANSI C compiler, so do not use C language facilities in space.c files or the header files they call unless it is defined in the Kernighan and Ritchie C Language. The main driver code should be compiled with the standard SCO OpenServer 5 C compiler which is ANSI compliant.
See ``Writing drivers in C++'' for notes about writing drivers in C++.