This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: const issues
On Fri, Feb 29, 2008 at 2:06 AM, Dario Saccavino <kathoum@gmail.com> wrote:
> Hi Jason,
>
> your code isn't valid C. A global variable can only be initialized
> with a compile-time constant, and a const variable isn't a
> compile-time constant in C. Compare with the following program:
>
>
> #include <stdlib.h>
>
> const int a = 42;
> const int b = a; // Error
>
> int main()
> {
> return 0;
> }
>
> See e.g. http://c-faq.com/ansi/constasconst.html
>
> By contrast, in C++ a global const integral variable is a compile-time
> constant, and you can use it as an initializer.
Ahh, that must have been the source of my confusion. Thanks!
-jason