www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/26/14:40:09

Xref: news-dnh.mv.net comp.os.msdos.djgpp:2199
Path: news-dnh.mv.net!mv!news.sprintlink.net!EU.net!Belgium.EU.net!chaos.kulnet.kuleuven.ac.be!verhaege
From: verhaege AT esat DOT kuleuven DOT ac DOT be (Wim Verhaegen)
Newsgroups: comp.os.msdos.djgpp
Subject: Problems with linking of pure virtual functions: the solution!
Date: 26 Sep 1995 14:20:34 GMT
Organization: K.U.Leuven
Lines: 33
Nntp-Posting-Host: kwak.esat.kuleuven.ac.be
Keywords: pure virtual
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

For all those who have problems with linking pure virtual functions,
here's the solution (which I've found thanks to the hints given by 
Gordon J. Hogenson).

The problem is in libgcc.a: it must contain a module called ___pure_virtual.
(Yes, with 3 leading underscores.) If it's not there, you can install a newer version
of libgcc.a (which isn't easy to find), but it's much easier and cheaper to fix
it yourself.

First you make a C file consisting of the following line:

void __pure_virtual(void) { abort(); }

Note 1: it really has to be a C file, as the C++ compiler puts type information
	in the module name.
Note 2:	There HAVE to be exactly 2 leading underscores in the function name.
Note 3: The abort() isn't really necessary. The use of pure virtual functions
	makes the class an abstract data class. You can't create an object of this
	class, so you can't call the member functions either! (But don't forget
	to override them in the derived classes.)

Then you compile this file and put the resulting .o file in libgcc.a with the
following command:

	as rv libgcc.a <name of the .o file>

This should do the trick!

--
Wim Verhaegen                       |  The man who got obsessed by pure virtual functions.
Dept. of Electrical Engineering     |  
KU Leuven, Belgium                  |
wim DOT verhaegen AT esat DOT kuleuven DOT ac DOT be   |  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019