This is the mail archive of the gcc-help@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]

const issues


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]