what's thie meaning for "#ifndef __C51__"

In Keil demos, I find some definitions such as "#ifndef __C51__", what's the meaning for double '_'.

Parents
  • As opposed to Pascal language, C language suffers from the lack of name spaces. There is no way in to import resources from a module in C/C++, the file is included as a whole. As a result, if you include modules A and B, whereas module B uses module A, you have a redifinitions and other conflicts. In other words, the global scope is a big mess. #ifndefs in H files solve this problem paritally. Returning to example, module A is included only once wrapped into #ifndef condition.
    It is widely adopted in C programming to use module names as identificators with double subscribts. For example,
    #ifndef __moduleA_H__
    #define __moduleA_H__
    // this H file will be included only once
    //definitions here
    #endif

Reply
  • As opposed to Pascal language, C language suffers from the lack of name spaces. There is no way in to import resources from a module in C/C++, the file is included as a whole. As a result, if you include modules A and B, whereas module B uses module A, you have a redifinitions and other conflicts. In other words, the global scope is a big mess. #ifndefs in H files solve this problem paritally. Returning to example, module A is included only once wrapped into #ifndef condition.
    It is widely adopted in C programming to use module names as identificators with double subscribts. For example,
    #ifndef __moduleA_H__
    #define __moduleA_H__
    // this H file will be included only once
    //definitions here
    #endif

Children
More questions in this forum