Re: constants question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 06.02.2008 um 14:04 schrieb Benoit Fouet:

Hi,

Lars Poeschel wrote:
Hello!

I have the following 2 lines of c-code:

const char* const barEN = "bar";

try with const char barEN[] = "bar";

This would not be exactly what I want, but:

const char const barEN[] = "bar";

works. I don't know why and whats the difference, but it works. Thank you very much!


const char * const arrayEN[] = {
    "foo", barEN };

./src//globals.c:20: error: initializer element is not constant
./src//globals.c:20: error: (near initialization for 'arrayEN[1]')

I don't know why. The first line defines a constant pointer variable
that points to a const char*. What could be more const here ?
The second line then defines a const array arrayEN, thats contents
have to be string constants (const char*). It is initialized with the
real constant "foo" and a constant variable. Why is it not working ?
What is the difference between the constant "foo" and the const
variable barEN ?
I tryed gcc 4.0.1 and gcc 4.1.2

Thanks,

Lars

--
Ben

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkepuHEACgkQ3m3cZ1XsbwdgvQCfWKlUsVB6OUolsl/E0Drrx+Sg
WggAniG+yjHD8C7q8WAHD20yNj5BfHWD
=kjn6
-----END PGP SIGNATURE-----

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux