---
name: "DECLARE_MODULE"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/DECLARE_MODULE"
---

# DECLARE\_MODULE(9)

kernel module declaration macro

## NAME

**DECLARE\_MODULE** – kernel module declaration macro

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/kernel.h\>**

**#include \<sys/module.h\>**

**DECLARE\_MODULE**(*name*, *moduledata\_t data*, *sub*, *order*);

## DESCRIPTION

The **DECLARE\_MODULE**() macro declares a generic kernel module. It is used to register the module with the system, using the **SYSINIT**() macro. **DECLARE\_MODULE**() is usually used within other macros, such as [DRIVER\_MODULE(9)](/DRIVER_MODULE/9.md), [DEV\_MODULE(9)](/DEV_MODULE/9.md) and [SYSCALL\_MODULE(9)](/SYSCALL_MODULE/9.md). Of course, it can also be called directly, for example in order to implement dynamic sysctls.

The arguments it expects are:

- *name*

  The module name, which will be used in the **SYSINIT**() call to identify the module.

- *data*

  A *moduledata\_t* structure, which contains two main items, the official name of the module name, which will be used in the *module\_t* structure and a pointer to the event handler function of type *modeventhand\_t*.

- *sub*

  An argument directed to the **SYSINIT**() macro. Valid values for this are contained in the *sysinit\_sub\_id* enumeration (see ⟨sys/kernel.h⟩) and specify the type of system startup interfaces. The [DRIVER\_MODULE(9)](/DRIVER_MODULE/9.md) macro uses a value of SI\_SUB\_DRIVERS here for example, since these modules contain a driver for a device. For kernel modules that are loaded at runtime, a value of SI\_SUB\_EXEC is common.

- *order*

  An argument for **SYSINIT**(). It represents the KLDs order of initialization within the subsystem. Valid values are defined in the *sysinit\_elem\_order* enumeration (In sys/kernel.h).

## SEE ALSO

[DEV\_MODULE(9)](/DEV_MODULE/9.md), [DRIVER\_MODULE(9)](/DRIVER_MODULE/9.md), [module(9)](/module/9.md), [SYSCALL\_MODULE(9)](/SYSCALL_MODULE/9.md)

*/usr/include/sys/kernel.h*, */usr/share/examples/kld*

## AUTHORS

This manual page was written by Alexander Langer ⟨alex@FreeBSD.org⟩, inspired by the KLD Facility Programming Tutorial by Andrew Reiter ⟨arr@watson.org⟩.
