Re: const issues

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

 



On Fri, Feb 29, 2008 at 2:06 AM, Dario Saccavino <kathoum@xxxxxxxxx> 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

[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