This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: string literals in struct initializers with C++


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]