This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: string literals in struct initializers with C++
- From: Michael Ritzert <mritzert at ti dot uni-mannheim dot de>
- To: jtc at acorntoolworks dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 15 Oct 2002 20:55:42 +0200
- Subject: Re: string literals in struct initializers with C++
- References: <87vg43bn4i.fsf@orac.acorntoolworks.com>
On Tuesday 15 October 2002 19:58, J.T. Conklin wrote:
> The following code:
>
> struct foo {
> char x[20];
> int y;
> int z;
> };
>
> struct foo foos[] = {
> { "foo", 0, 2 },
> { "bar", 1, 3 }
> };
>
> Now results in:
> foo.cc:10: error: invalid conversion from `const char*' to `char'
> foo.cc:10: error: invalid conversion from `const char*' to `char'
I hit the same error message during my daily build of STLport. The simplified
code looks like this:
-bash-2.05b$ gcc -v
Reading specs from
/home/ritzert/gcc-HEAD/install/lib/gcc-lib/i386-unknown-freebsd4.5/3.3/specs
Configured with: /home/ritzert/gcc-HEAD/gcc/configure --enable-threads=posix
--prefix=/home/ritzert/gcc-HEAD/install
Thread model: posix
gcc version 3.3 20021014 (experimental)
-bash-2.05b$ cat x.cpp
const char x[][2] = { "Hello", "world" };
-bash-2.05b$ gcc -c x.cpp
x.cpp:1: error: invalid conversion from `const char*' to `char'
x.cpp:1: error: invalid conversion from `const char*' to `char'
It compiled fine just a week ago. (Sorry, I can't be more precise; first there
was the anoncvs update problem, then my build machine went down...).
Michael