delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/08/30/22:02:09

From: ebritten AT uci DOT edu (Eric Britten)
Subject: Missing virtual functions
30 Aug 1997 22:02:09 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <33FF524B.7B256D82.cygnus.gnu-win32@uci.edu>
Mime-Version: 1.0
X-Mailer: Mozilla 4.01 [en] (Win95; I)
Original-To: gnu-win32 AT cygnus DOT com
X-Priority: 3 (Normal)
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Yesterday I found that if one declares virtual functions in a class
like:

class A
{
    A();
    virtual void B();
};

and the definitions for the functions(inline or external) are not found
by the linker then two types of linking errors result.

1.  Undefined reference to a vtable in the constructors of the class.
2.  Undefined reference to any other inline functions of the class that
are used by other code.

It took me a while to figure out that if all virtual functions are
defined, then these errors go away.  Is this GNU specific?  It would
help if the linker complained of undefined references to the virtual
function without a definition, rather than the missing vtable.  Of
course this would help those unfamiliar with this error, I already know
the cause.

Eric Britten

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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