www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linker complaining about interface methods

reply Daniel Keep <daniel.keep.lists gmail.com> writes:
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

-- 
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/
Apr 05 2007
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
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/
Apr 05 2007
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Ok, I worked out how to fix it.

The IFieldParser interface was private to the module.  Once I made it
public, it worked.

I just wasted a day because DMD barfed on a private interface :'(

If you'll excuse me, I need to go quietly sob in the corner...

	-- 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/
Apr 06 2007
parent Dan <murpsoft hotmail.com> writes:
Daniel Keep Wrote:
 I just wasted a day because DMD barfed on a private interface :'(
 
 If you'll excuse me, I need to go quietly sob in the corner...
Heh. It's hard getting help on Good Friday. The christians are all out worshiping statues of Jesus and stuff, and we're all out partying. The definition of "private" is "will not be seen by the linker". I feel for ya though man. I've spent days on stupid shit like that too, and it really does make ya wanna cry. That's what pair programming is for though. So you can have someone else see it for you. And... take a break man, it's the weekend. Sincerely, me
Apr 06 2007