const issues

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

 



this compiles as expected:


#include <stdlib.h>

int main()
{
    const int a = 42;
    const int * const b = &a;
    const int * const c = b;

    return EXIT_SUCCESS;
}


but moving the variables outside of the function causes gcc to die
with "error: initializer element is not constant" on line 5 (the "c =
b" line):


#include <stdlib.h>

const int a = 42;
const int * const b = &a;
const int * const c = b;

int main()
{
    return EXIT_SUCCESS;
}


As best as I can tell, the error is a lie: I can't make that  any more
const than it already is.

ideas?

-jason pepas

[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