[comp.lang.c++] The +e option

keith@nih-csl.UUCP (keith gorlen) (07/10/87)

*>> > A simple approach to using the +e option is to use +e0 (only include
*>> > external reference to virtual table) for all .c files, and compile
*>> > the .h files containing the class declarations using +e1 (generate
*>> > globally accessible virtual tables).
*>> 
*>> This won't work on my .h files -- I usually have derived classes.
*>> ...
*>> Have I misunderstood something?
*>
*>	Yes, I think so.  You compile D1.c and D2.c with +e0.  D1.o
*>	and D2.o then refer to some external vtbls, including the
*>	one for class B.  You then compile a file (or set of files
*>	if there are some conflicts) containing only header files,
*>	call it headers.c, with +e1.  Now, headers.o contains the
*>	definitions for the vtbls, and ld takes care of the rest.

Sure, if I'm willing to write a SINGLE headers.c that #includes ALL
the class declarations used by a particular program, then this works.
But this isn't terribly convenient if I have a class library that I
wish to link with my programs.  If all the modules in the library are
compiled with +e0, I have to be sure to #include the class
declarations used internally by any library components my programs
call in the headers.c file, and that means I have to know a lot about
how the library is put together.  I can't just include them all
either, because the external references from the vtbls in header.c
will cause just about everything from the library to be linked with my
program.  And you can't in general compile more than one header file
with +e1 because of the problem with derived classes that I described
previously.  So I still maintain that the +e option is a pain to use!
-- 
	Keith Gorlen			phone: (301) 496-5363
	Building 12A, Room 2017		uucp: seismo!elsie!nih-csl!keith
	National Institutes of Health
	Bethesda, MD 20892