Search code examples
c++c-preprocessorreserved-words

C++ using C code using double underscores in defines and identifiers


I understand that in C++ double underscores in identifiers are reserved for the compiler. I have some C code which has characteristics similar to this in the corresponding header files:

extern "C" {
    #define HELLO__THERE 1
    int hello__out__there( int );
}

I will be using this header in a C++ project, and plan to be doing things in C++ like:

if (HELLO__THERE == abc) 
    hello__out__there(foo);

Is this acceptable behavior in C++, covered by the standard?


Solution

  • double underlines in identifiers are reserved for the compiler

    First, it's underscore I guess. Second such identifiers are reserved. That doesn't hold one back to not use it. You can use it (until there is no naming conflict).

    Is this acceptable behavior in C++, covered by the standard?

    Yes. It's acceptable. However, there is difference between acceptable and good code. If you are following a proper coding guidelines then your code will be good as well as acceptable. IMHO, you should refer to some good coding standards on internet; it will help you a lot.