[過去ログ] C++相談室 part154 (1002レス)
上下前次1-新
抽出解除 レス栞
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
341(1): はちみつ餃子 ◆8X2XSCHEME 2021/01/31(日)10:57 ID:+XHxoAeu(1/5) AAS
>>339
繰り返すが言語仕様上はグローバル変数ではない名前の頭がアンダースコアで始まるだけなら問題ない。
現実に出来が悪いコンパイラがたくさんあるのであれば仕方がないが、
少なくとも俺はそんなのに遭遇したことはない。
345(1): 2021/01/31(日)13:12 ID:ZnRwde8F(1/13) AAS
>>341
英語サイトでも、説明の仕方が誤解を招くようなものがありまして、もしかしたらそれは誤解かも知れません。
外部リンク:stackoverflow.com
「Here's what the C standard says (section 7.1.3):
1. All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
2. All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.」
訳:
1. アンダースコアで始まって直後に英大文字が続くか、または、アンダースコアが連続して
続く識別子は、いかなる使用も予約されている。
2. アンダースコアで始まる全ての識別子は、通常または、タグ名前空間における
ファイルスコープの識別子として常に予約されている。
1. の方は、_XXX か、__xxx は予約されていると言うことですが、
2. の方は、_xxx の形式は、例え xxx の部分の先頭が小文字であっても、ファイルスコープにおける
識別子として予約されており、ローカル変数名としては使うべきではないということだと思われます。
また、C++の方では、
外部リンク:stackoverflow.com
*Reserved in any scope, including for use as implementation macros:
10. identifiers beginning with an underscore followed immediately by an uppercase letter
11. identifiers containing adjacent underscores (or "double underscore")
*Reserved in the global namespace:
12. identifiers beginning with an underscore
この12.の書き方が(あなたに)誤解を招いた気がします。
また、11.によれば、xxx__yyy のように _ が連続するものは、識別子の中間であっても予約されている
とのことです。
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.029s