Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C预处理器中的强氧如果_C_Header_Documentation_C Preprocessor_Doxygen - Fatal编程技术网

C预处理器中的强氧如果

C预处理器中的强氧如果,c,header,documentation,c-preprocessor,doxygen,C,Header,Documentation,C Preprocessor,Doxygen,我用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 s

我用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
#包括
/**
*@brief这是第一个testfunction
*@返回无效
*/
void testFunc1(void)
{
//…做事
}
#如果启用
/**
*@brief这是第二个testfunction
*@返回无效
*/
void testFunc2(void)
{
//…做事
}
#恩迪夫
Doxygen找到testFunc1并对其进行了良好的文档记录,但找不到testFunc2。在.doxy文件中定义ENABLED无法解决我的问题


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

[误读源代码片段]

您可能想要
#ifdef
而不是
#if

从以下文件:

“#if”
指令允许您测试算术表达式的值,而不仅仅是一个宏的存在。 它的语法是

#if expression
controlled text
#endif /* expression */
表达式是整数类型的C表达式,受严格限制

以及:

最简单的条件类型是

#ifdef MACRO
controlled text
#endif /* MACRO */
此块称为条件组。当且仅当定义了宏时,受控文本才会包含在预处理器的输出中。我们说,如果定义了宏,则条件成功;如果未定义宏,则条件失败。


您可能希望使用
#ifdef
而不是
#if
。但我将其定义为1(#定义启用1),因此#if启用应该是true@xy36这是很难看到它,因为1是非常远的休息。我会编辑的是的,我看到你已经编辑过了。我们使用第60列的空格,所以…ThanksTry
#include“defines.h”
而不是
#include
。我刚才看到:
#define ENABLED 1
。1在右边有很多空格,真是可笑。所以这不是问题所在。@Jean-Françoisfare:哦,是的。。。将很快删除。我猜OP包含了错误的defines.h文件。似乎Doxygen无法包含headerfile并读取#defineth这是可能的,是的。。。不能直接从doxygen命令行添加指令吗?还是在conf文件中?