C言語の事訊いて!!!第.38支部
■ このスレッドは過去ログ倉庫に格納されています
0774デフォルトの名無しさん
NGNG>のは何故だ?
規格にそう書いてあるから。
6.3.2.3 (2) For any qualifier q, a pointer to a non-q-qualified
type may be converted to a pointer to the q-qualified
version of the type; the values stored in the original and
converted pointers shall compare equal.
>> Tとconst char *は別の型だから。
>char* が const char* に変換できないなら、char は const char に変換でき
>ないのか?
>いいや違う。
>
>char* は const char* に変換できる。
>でなければ strcmp() 等はプロトタイプが間違っている事になるが、実際はそ
>うではない。
T * → T const *はOKなので、
char * → char const *はOKだよ。(T=char)
char ** → char *const *もOK。(T=char*)
char ** → char const **はダメ。(Tをどう置いてもうまくいかない。)
>だが、char* が const char* に変換できないとはどこに書いてある?
どこにも書いてないよ。
>char** は、const char** の役割を充分に果たす。
>なのに compatible でないと言いきるのか?
規格は言いきってるね。
6.7.6.1 (2) For two pointer types to be compatible, both shall be
identically qualified and both shall be pointers to
compatible types.
■ このスレッドは過去ログ倉庫に格納されています