T
Tom Plunket
Hey gang;
In C++ I often used forward declarations to allow me to get away with
not including additional files in headers, if in fact all I needed was
to know that a type existed.
e.g.
foo.h:
struct Bar;
void Foo(Bar* b);
....and then foo.cpp would presumably include bar.h, if in fact it
needed to know what Bar consisted of.
How can I accomplish a similar thing in (legal) C?
I've tried the C++ forward-declaration strategy, e.g.
struct Bar;
void Foo(struct Bar* b);
....but I get a compilation failure when struct Bar is actually defined
in a subsequent #include.
I've also tried
void Foo(struct Bar* b);
....all by itself, but that yields a compilation warning about the
definition of struct Bar being only in the scope of this function.
So, can I, and if I can, how can I accomplish what I'm trying to do in
somewhat-pedantic, warning-free C?
thx,
-tom!
In C++ I often used forward declarations to allow me to get away with
not including additional files in headers, if in fact all I needed was
to know that a type existed.
e.g.
foo.h:
struct Bar;
void Foo(Bar* b);
....and then foo.cpp would presumably include bar.h, if in fact it
needed to know what Bar consisted of.
How can I accomplish a similar thing in (legal) C?
I've tried the C++ forward-declaration strategy, e.g.
struct Bar;
void Foo(struct Bar* b);
....but I get a compilation failure when struct Bar is actually defined
in a subsequent #include.
I've also tried
void Foo(struct Bar* b);
....all by itself, but that yields a compilation warning about the
definition of struct Bar being only in the scope of this function.
So, can I, and if I can, how can I accomplish what I'm trying to do in
somewhat-pedantic, warning-free C?
thx,
-tom!