Topic: Forward declarations of types and linking
Author: nwilson@lnis116.is.morgan.com (Ab Wilson)
Date: Tue, 30 Aug 1994 15:08:20 GMT Raw View
Did anyone see this message or was I wasting my breath?
In article <NWILSON.94Aug19143245@lnis116.is.morgan.com> nwilson@lnis116.is.morgan.com (Ab Wilson) writes:
Newsgroups: comp.std.c++
Path: is1.is.morgan.com!is0.is.morgan.com!nwilson
From: nwilson@lnis116.is.morgan.com (Ab Wilson)
Sender: news@is.morgan.com
Nntp-Posting-Host: lnis116
Organization: /u/nwilson/.organization
Distribution: World
Date: Fri, 19 Aug 1994 13:32:45 GMT
Lines: 52
Are the following issues addressed in ANSI?
At present this code isn't legal (well not with any compiler I've
used).
class Foo;
void f(Foo*);
typedef SomeTemplate<SomeType> Foo;
or
enum Foo { foo, bar };
Why should I have to know what kind of type I'm predeclaring? What if
I change the implementation at some later date? I think the above code
should be legel since it would reduce the ammount of coupling required
between header files.
Another proposal...
If I have
class Wibble
{
public:
virtual void wobble();
};
and wobble is never defined, I can't link an executable that uses a
Wibble even if wobble is never used. (This is because Wibble's vtbl
has to be filled in with the address of wobble.)
For a real instance of where this becomes a pain imagine a system
developed from two libraries. One library deals with the application
types (models), the other deals with GUI code (views). I'd like to be
able to keep the two libraries separate so that I can build test
programs that don't have to link with the GUI code. However I also
want my models to have a virtual makeView method. I would like the
standard to specify that the linker should not complain about wobble
being undefined.
Both these issues affect real developers. Neither would break existing
code or add new constructs to the language. If I've missed something
and these issues have already been addressed then please forgive me.
Could any followups be directed to me personally since I am not a
regular reader of this group.
Ab.
Author: nwilson@lnis116.is.morgan.com (Ab Wilson)
Date: Fri, 19 Aug 1994 13:32:45 GMT Raw View
Are the following issues addressed in ANSI?
At present this code isn't legal (well not with any compiler I've
used).
class Foo;
void f(Foo*);
typedef SomeTemplate<SomeType> Foo;
or
enum Foo { foo, bar };
Why should I have to know what kind of type I'm predeclaring? What if
I change the implementation at some later date? I think the above code
should be legel since it would reduce the ammount of coupling required
between header files.
Another proposal...
If I have
class Wibble
{
public:
virtual void wobble();
};
and wobble is never defined, I can't link an executable that uses a
Wibble even if wobble is never used. (This is because Wibble's vtbl
has to be filled in with the address of wobble.)
For a real instance of where this becomes a pain imagine a system
developed from two libraries. One library deals with the application
types (models), the other deals with GUI code (views). I'd like to be
able to keep the two libraries separate so that I can build test
programs that don't have to link with the GUI code. However I also
want my models to have a virtual makeView method. I would like the
standard to specify that the linker should not complain about wobble
being undefined.
Both these issues affect real developers. Neither would break existing
code or add new constructs to the language. If I've missed something
and these issues have already been addressed then please forgive me.
Could any followups be directed to me personally since I am not a
regular reader of this group.
Ab.