EmbeddedRelated.com
Forums

inizializing static const structures

Started by Mastupristi January 25, 2005
Roberto Waltman wrote:
>
... snip ...
> > What C is missing is forward declarations, a la Pascal ...
It has them, except they are called prototypes. Neither language can forward declare a variable. Both can declare pointers to undefined types. Pascal simply says that all pointers occupy the same storage space. C uses the incomplete type. -- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson
Roberto Waltman <usenet@rwaltman.net> wrote:

> What C is missing is forward declarations, a la Pascal ...
C is has all the forward declarations it needs. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
On Tue, 25 Jan 2005 18:30:34 -0500, Roberto Waltman
<usenet@rwaltman.net> wrote:

>iddw@hotmail.com wrote: >>If you can't, I believe the following is supposed to work as well: >> >> extern const Node_t n1,n2,n3; >> >> static const Node_t n1 = { &n2, &n3, "Node 1" }; >> static const Node_t n2 = { &n3, &n1, "Node 2" }; >> static const Node_t n3 = { &n1, &n2, "Node 3" }; >> >>This is apparently how things were done before the standard, and the >>standard supports the old code. > >gcc accepts that, unless you are using the "-pedantic" switch. Then it >produces warnings, (not errors,) about "static declaration following >non-static".
Actually, I mis-spoke. Change the first line to const Node_t n1,n2,n3; (i.e., remove the "extern" and leave off the "static") and it should be legal.
> >What C is missing is forward declarations, a la Pascal ...
Not C, just the OP's compiler. Regards, -=Dave -- Change is inevitable, progress is not.