-1

Why inside myheader.h, we write:

#ifndef MYHEADER_H
#define MYHEADER_H
...
#endif

Since, Identifiers are case-sensitive (lowercase and uppercase letters are distinct), and every character is significant. How the above is valid? It should be

#ifndef myheader.h
#define myheader.h
...
#endif

What is the purpose of the underscores? What if I have 2 separate header files with names: MyHeader.h and myheader.h, How does the preprocessor distinguish between these?

Porcupine
  • 5,885
  • 2
  • 19
  • 28
  • 1
    Read: [What are the rules about using an underscore in a C++ identifier?](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier) – WhozCraig Feb 25 '17 at 10:53

1 Answers1

1

The leading underscore followed by uppercase indicates that it's either a name defined by the C++ implementation, because this form is reserved for the implementation, or it's a name defined by someone who has seen this in system headers and just copy-cat adopted it without understanding it.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331