Re: iconv...


Subject: Re: iconv...
From: Mike Nordell (tamlin@algonet.se)
Date: Fri Nov 10 2000 - 16:35:30 CST


Dom Lachowicz wrote:
> Ok, sorry for breaking win32. Apparantly, the compiler can't convert a
"char
> **" to a "const char **" which seems silly to me. Does anyone have a
> suggestion for how to handle this?

Not at all. Well, yes, of course I have a solution, but not without
explaining the problem (the "silly part", whithout we wouldn't have a type
system in C++).
I think it's time for "types 101" now. :-)

A "char**" is a pointer to a "char pointer".
A "const char**" is the same as "char const**", which is a pointer to a
"const char pointer".

See the difference? A pointer to a "char pointer" _can't ever_ be
interchangeable with a pointer to a "const char pointer". These pointers are
pointing to two different _types_.

 What _can_ be done is to convert those
  char** p1
to
  char* const * p2

That is, a pointer to a char pointer can be converted to a const pointer to
a char pointer.

Remember, "const char*" and "char*" are two _different types_. You can't
create pointers to those two types and expect them to be interchangeable.

(note: don't take my word for these examples, I've also been known to make
errors even in comp.lang.c++.moderated why I'd like your own judgement and
experiments be _your_ authority in this case).

/Mike



This archive was generated by hypermail 2b25 : Fri Nov 10 2000 - 16:34:09 CST