> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/module_depend.9.md).

# MODULE\_DEPEND.9

`MODULE_DEPEND` — 设置内核模块依赖

## 名称

`MODULE_DEPEND`

## 概要

```c
#include <sys/param.h>
#include <sys/module.h>

MODULE_DEPEND(name, moddepend, int minversion, int prefversion, int maxversion)
```

## 描述

`MODULE_DEPEND` 宏设置对另一个名为 `moddepend` 的内核模块的依赖，该模块已通过 `MODULE_VERSION` 注册了其版本。

`MODULE_DEPEND` 宏向内核 [loader(8)](/man/man8/loader.8.md) 和内核链接器提供提示，以确保指定的依赖项在当前模块之前加载。它不会改变或决定模块在运行时初始化的顺序。

必须为 `moddepend` 指定三个版本：

**`minversion`** 当前模块可以依赖的最低版本。

**`maxversion`** 当前模块可以依赖的最高版本。

**`prefversion`** 当前模块首选依赖的版本。

## 实例

```c
MODULE_DEPEND(foo, bar, 1, 3, 4);
```

## 参见

[DECLARE\_MODULE(9)](/man/man9/declare_module.9.md), [module(9)](/man/man9/module.9.md), [MODULE\_VERSION(9)](/man/man9/module_version.9.md)

## 作者

本手册页由 Alexander Langer <alex@FreeBSD.org> 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/module_depend.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
