下線と二重下線の接頭辞
2204 ワード
プログラムで下線、二重下線、strを定義します.「is」、「to」はansiC標準委員会に保持されており、自分で定義するとエラーが発生します.また、すべての標準ライブラリで定義されている識別子(変数名、マクロ、関数名......)は使用しないほうがいいです.特に好きな場合は、変数名の前に個性的な接頭辞を付けることをお勧めします.(NMD_,FUCK_など…,何?私の悪口?NO,清華大学の学生-伏明盲目は知らないが,私は何を意味するか分からない)あるいは接尾辞を添えて_DOG,_CS……. 以下はRichard Heathfield Lawrence Kirbyなどの推奨(遠慮)使用しない標準識別子または接頭辞:E[0-9]*E[A-Z]*is[a-z]*LC[A-Z]*mem[a-z]*NDEBUG Offsetofrise SIG[A-Z]*str[a-z]*to[a-z]*wcs[a-z]*特に、多くの人が形式識別子を定義するのが好きで、危険です.MY_HEARD_H _MY_ALLOC_H _YOUR_MOTHER_PP_H
Following contents are from Sam's book "C++ Premier Plus (5th edition)", page 67.
Names beginning with two underscore characters or with an underscore character followed by an uppercase letter are reserved for use by the implementation—that is, the compiler and the resources it uses. Names beginning with a single underscore character are reserved for use as global identifiers by the implementation.
The next-to-last point is a bit different from the preceding points because using a name such as __time_stop or _Donut doesn’t produce a compiler error; instead, it leads to undefined behavior. In other words, there’s no telling what the result will be. The reason there is no compiler error is that the names are not illegal but rather are reserved for the implementation to use.
The final point differentiates C++ from ANSI C (C99), which guarantees only that the first 63 characters in a name are significant. (In ANSI C, two names that have the same first 63 characters are considered identical, even if the 64th characters differ.)
Here are some valid and invalid C++ names:
Following contents are from Sam's book "C++ Premier Plus (5th edition)", page 67.
Names beginning with two underscore characters or with an underscore character followed by an uppercase letter are reserved for use by the implementation—that is, the compiler and the resources it uses. Names beginning with a single underscore character are reserved for use as global identifiers by the implementation.
The next-to-last point is a bit different from the preceding points because using a name such as __time_stop or _Donut doesn’t produce a compiler error; instead, it leads to undefined behavior. In other words, there’s no telling what the result will be. The reason there is no compiler error is that the names are not illegal but rather are reserved for the implementation to use.
The final point differentiates C++ from ANSI C (C99), which guarantees only that the first 63 characters in a name are significant. (In ANSI C, two names that have the same first 63 characters are considered identical, even if the 64th characters differ.)
Here are some valid and invalid C++ names:
int poodle; // valid
int Poodle; // valid and distinct from poodle
int POODLE; // valid and even more distinct
Int terrier; // invalid -- has to be int, not Int
int my_stars3 // valid
int _Mystars3; // valid but reserved -- starts with underscore
int 4ever; // invalid because starts with a digit
int double; // invalid -- double is a C++ keyword
int begin; // valid -- begin is a Pascal keyword
int __fools; // valid but reserved – starts with two underscores
int the_very_best_variable_i_can_be_version_112; // valid
int honky-tonk; // invalid -- no hyphens allowed