gpt4 book ai didi

c - C 预处理器中的 Doxygen 如果

转载 作者:太空宇宙 更新时间:2023-11-04 00:00:09 24 4
gpt4 key购买 nike

我用 Doxygen 记录了我的 C 代码并遇到了问题。考虑以下示例:

在定义.h中:

#ifndef DEFINES_H_
#define DEFINES_H_

#define ENABLED 1

#endif

在测试.c中

#include <defines.h>

/**
* @brief This is the first testfunction
* @return void
*/
void testFunc1(void)
{
//...do stuff
}

#if ENABLED
/**
* @brief This is the second testfunction
* @return void
*/
void testFunc2(void)
{
//...do stuff
}
#endif

Doxygen 找到了 testFunc1 并记录了它,但是找不到 testFunc2。在 .doxyfile 中定义 ENABLED 不会解决我的问题。

有没有办法让它运行起来? (注意,我需要在我的 c-Project 中定义 ENABLED!)

最佳答案

[误读源代码片段]

你可能想要 #ifdef而不是 #if .

<罢工>

来自 #if 的文档:

The ‘#if’ directive allows you to test the value of an arithmetic expression, rather than the mere existence of one macro. Its syntax is

#if expression
controlled text
#endif /* expression */

expression is a C expression of integer type, subject to stringent restrictions.

#ifdef :

The simplest sort of conditional is

#ifdef MACRO
controlled text
#endif /* MACRO */

This block is called a conditional group. controlled text will be included in the output of the preprocessor if and only if MACRO is defined. We say that the conditional succeeds if MACRO is defined, fails if it is not.

关于c - C 预处理器中的 Doxygen 如果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48164743/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com