constants question

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

 



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

Hello!

I have the following 2 lines of c-code:

const char* const barEN = "bar";
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 -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkepqtsACgkQ3m3cZ1XsbwcihwCgjSljec0QIXWkPubWjUd2MYCt
HigAoIr/iNmSeqDdHihTTQ/WVEkJA08Q
=pklv
-----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