Linker complaining about interface methods -- at wits end

Daniel Keep daniel.keep.lists at gmail.com
Thu Apr 5 22:49:42 PDT 2007



Daniel Keep wrote:
> Ugh.
> 
> I'm currently knee-deep in trying to get this code to work, and the
> linker spits this out at me:
> 
> util\dataset.obj(dataset)
>  Error 42: Symbol Undefined _D4util7dataset12IFieldParser7getDataMFZAh
> 
> Here's the definition of IFieldParser:
> 
> interface IFieldParser : ContentHandler
> {
>     ubyte[] getData();
> }
> 
> Where ContentHandler is just the SAX interface (which doesn't have a
> getData method).
> 
> The "getData" method is used exactly twice in the code on instances of
> IFieldParser:
> 
> IFieldParser fieldParser;
> // ...
> fieldParser.getData();
> 
> If I comment the "fieldParser.getData" lines out, the code compiles and
> links fine.
> 
> Anyone have *any* idea what's going on here?
> 
> 	-- Daniel
> 

After a few hours sleep, I've upgraded to DMD v1.010 (on the off chance
that fixed it), but that didn't help.

I tried changing the "fieldParser.getData()" calls to
"fieldParser.getFieldData()" *without* changing the actual interface or
the classes.  As expected, the compiler omitted some errors:

dataset.dw(244): Error: no property 'getFieldData' for type
'util.dataset.IFieldParser'
dataset.dw(244): Error: function expected before (), not 1 of type int
dataset.dw(243): function
util.dataset.IParserControl.setCellField(CellID ,char[],ubyte[]) does
not match parameter types (CellID ,char[],int)
dataset.dw(244): Error: cannot implicitly convert expression (1()) of
type int to ubyte[]

So it's clearly seeing the method.  Just in case it just didn't like the
name "getData", I then went and changed the interface to read

interface IFieldParser : ContentHandler
{
    ubyte[] getFieldData();
}

Again, *did not* update the classes that implemented the interface --
they still had "getData" methods.  This time, it actually compiled, and
gave me a linker error:

util\dataset.obj(dataset)
 Error 42: Symbol Undefined _D4util7dataset12IFieldParser12getFieldDataMFZAh

So the compiler can obviously *see* the method, but for some reason,
it's ignoring the fact that it's on an interface, and is apparently
treating it as a static member function!  Not only that, but the classes
that implement the interface apparently aren't being checked to make
sure they implement this method!

It gets weirder.  The classes that implement IFieldParser also have to
implement the SAX ContentHandler interface.  If I take one of the
methods from *that* interface, say "characters", and rename it to
"_characters", compilation fails saying that:

util\dataset.d(689): class
util.dataset.SimpleParser!(bool,toBool).SimpleParser interface function
IFieldParser.characters isn't implemented

I'm completely out of ideas.  Does *anyone* have any thoughts on what's
going on?  Pretty please? :(

	-- Daniel

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/



More information about the Digitalmars-d mailing list