#ifndef BOOL
#define BOOL unsigned long
#endif或者
#ifndef NO_COMPRESS #define MINU_BUFFER_SIZE    (NUM_MINU*COMPRESSED_MINUSIZE)
#define FP_COMPRESS_FLAG    1L#else  
#define MINU_BUFFER_SIZE    (NUM_MINU*MINUSIZE)
#define FP_COMPRESS_FLAG    0#endif  
不知何意,其中的名字无所谓,谁能告诉我#ifndef啥意思,谢谢

解决方案 »

  1.   

    #ifndef是一个宏,表明如果没有定义后面的值,则如何如何.
    比如
    #ifndef  _TEST_H_
    #define _TEST_H_
       ....
    #endif
    如果没有定义 _TEST_H_就定义 _TEST_H_,如果定义了_TEST_H_,就略掉
    #ifndef #endif中间的代码
      

  2.   

    The #ifdef and #ifndef Directives
    The #ifdef and #ifndef directives perform the same task as the #if directive when it is used with defined( identifier ).Syntax#ifdef identifier#ifndef identifieris equivalent to #if defined identifier#if !defined identifierYou can use the #ifdef and #ifndef directives anywhere #if can be used. The #ifdef identifier statement is equivalent to #if 1 when identifier has been defined, and it is equivalent to #if 0 when identifier has not been defined or has been undefined with the #undef directive. These directives check only for the presence or absence of identifiers defined with #define, not for identifiers declared in the C or C++ source code. These directives are provided only for compatibility with previous versions of the language. The defined( identifier ) constant expression used with the #if directive is preferred.The #ifndef directive checks for the opposite of the condition checked by #ifdef. If the identifier has not been defined (or its definition has been removed with #undef), the condition is true (nonzero). Otherwise, the condition is false (0).Microsoft Specific The identifier can be passed from the command line using the /D option. Up to 30 macros can be specified with /D.This is useful for checking whether a definition exists, because a definition can be passed from the command line. For example:// PROG.CPP
    #ifndef test    // These three statements go in your source code.
    #define final
    #endifCL /Dtest prog.cpp // This is the command for compilation.END Microsoft Specific
    --------------------------------------------------------------------------------
    Send feedback to MSDN.Look here for MSDN Online resources.
      

  3.   

    判断是否已经定义
    if () {} else {}
    你明白的,这也一样
      

  4.   

    #ifndef..if no define如果沒有定義過BOOL那就定義BOOL為unsigned long.
      

  5.   

    #ifndef 是如果没有定义,就怎么样的意思!
      

  6.   

    #ifndef是一个宏,
    举个例子说明
    #ifndef _TEST_H_
    #define _TEST_H_
      ....
    #endif
    上面是说如果没有定义 _TEST_H_,则定义 _TEST_H_,并执行#ifndef #endif中的代码
    如果定义了_TEST_H_,编程程序则略掉#ifndef #endif中的代码
    上面的方法可以用来避免头文件重复包含.
      

  7.   

    这是条件编译吧,编译器在编译过程中,如果BOOL未被定义过(没有#define BOOL),则对“#define BOOL unsigned long”进行编译,否则,编译。目的是减少目标程序长度。
      

  8.   

    判断是否已经定义
    if (!())  //没有定义
    {
    //定义} else {}
      

  9.   

    简单的说,就是(拿BOOL的例子来说)
    如果宏定义过BOOL那么就将BOOL宏定义为unsigned long
    #ifdef
    ....(随便你干什么)
    #endif
    是个条件宏定义