This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How do I create/initialize a large class static (const?) array?
- From: Brian Dessent <brian at dessent dot net>
- To: Lee Rhodes <lee at rhoba dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 12 Aug 2007 21:57:38 -0700
- Subject: Re: How do I create/initialize a large class static (const?) array?
- References: <004101c7dd62$e7862450$0701a8c0@lee8075b>
- Reply-to: gcc-help at gcc dot gnu dot org
Lee Rhodes wrote:
> I need to create a class static (const?) array and then initialize it once
> when the first instance of the class is declared after which it should never
> be modified, only read. This array is too large to use the array {...}
> initializer syntax. I need to initialize the array with an algorithm.
>
> The following obviously does not work, but I'm not sure how to do it. (It is
> very easy in Java!)
This is a C++ language issue and not a gcc issue. A good book on C++
should explain why the code fails -- static data members must be defined
in exactly one unit. This page (and the rest of the site) is a good
resource: http://www.parashift.com/c++-faq-lite/ctors.html>. It
describes several ways of solving the problem you describe.
Brian