staticforward and C++
Greg Ewing
see at my.signature
Wed May 23 22:11:08 EDT 2001
Pete Shinners quoth:
>
> Therefore, the forward
> declaration should use the 'forwardstatic' keyword. This expands to
> static on most systems, but to extern on a few.
>From a brief experiment, it appears that g++ complains
about it either way!
However, I found that the following *does* work:
struct Foo {
int x;
};
void f() {
extern Foo foo;
foo.x = 42;
}
static Foo foo;
In other words, declare the struct as extern *inside*
each function which needs to use it, and then define
it as static later.
This is rather a nuisance, though. It appears that
there is no way to forward-declare a static variable
outside of a function in C++. Does anyone know if this
is what the language spec really requires, or is it
just an oversight on the part of g++?
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list