简体   繁体   English

C预处理器中的双氧,如果

[英]Doxygen in C preprocessor if

I document my C-Code with Doxygen and got a problem. 我用Doxygen记录了我的C代码并遇到问题。 Consider following example: 考虑以下示例:

in defines.h: 在define.h中:

#ifndef DEFINES_H_
#define DEFINES_H_

#define ENABLED 1

#endif

in test.c 在test.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 finds testFunc1 and documents it well, but it cannot find testFunc2. Doxygen找到了testFunc1并对其进行了很好的记录,但是找不到testFunc2。 To define ENABLED in the .doxyfile wont fix my problem. 在.doxyfile中定义ENABLED不会解决我的问题。

Is there a way to get this running? 有没有办法让它运行? (Note, I need to define ENABLED inside my c-Project!) (注意,我需要在c-Project中定义ENABLED!)

[misread the source snippet] [误读了源代码片段]

You probably want #ifdef instead of #if . 您可能需要 #ifdef而不是 #if

From the docs for #if : #if的文档中:

The '#if' directive allows you to test the value of an arithmetic expression, rather than the mere existence of one macro. '#if'指令允许您测试算术表达式的值,而不是仅测试一个宏的存在。 Its syntax is 它的语法是

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

expression is a C expression of integer type, subject to stringent restrictions. expression是整数类型的C表达式,受严格限制。

and for #ifdef : 对于 #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. 当且仅当定义了MACRO时, 受控文本才会包含在预处理器的输出中。 We say that the conditional succeeds if MACRO is defined, fails if it is not. 我们说,如果定义了MACRO ,则条件成功,如果未定义,则条件失败

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM