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

Re: const static initializers versionitis



I don't know how to "export" a symbol from an anonymous
namespace.  But somthing like that would make this ANS's
viable.

$ g++ -c yy.cpp
yy.cpp:20: parse error before `('

------------ yy.cpp ------------
namespace {

struct foo {
        const struct foo * y;
        char    who[ 10 ];
};

extern const struct foo bar[];

extern const struct foo tar[];

const struct foo bar[] = {
        tar, "bar"
};

const struct foo tar[] = {
        bar, "tar"
};

const char * ::zefuc()
{
        return tar->y->who;
}

};

Alexandre Oliva wrote:

> On Aug 22, 2000, Gianni Mariani <gianni@mariani.ws> wrote:
>
> > I want a "static" - so declaring it extern is specifically not
> > what I (ideally) would want. i.e. can't have an "extern static"
> > declaration.
>
> I see.  You'll hopefully have better luck with anonymous namespaces.
> AFAICT, there's no way to forward-declare static data items in C++.
>
> namespace {
>   extern const struct foo bar[];
>   extern const struct foo tar[];
>
>   const struct foo bar[] = { ... };
>   const struct foo tar[] = { ... };
> }
>
> --
> Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist    *Please* write to mailing lists, not to me


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]