Page 1 of 1

Error Adding Custom Function to Source Code

Posted: June 17th, 2012, 8:20 am
by Denyer
Hi there,

Hopefully someone can explain where I'm going wrong. I'm incredibly rusty at writing in C++ and I'm having trouble trying to add my own custom function.

Currently in igame.h I've added after the the suicide function:

Code: Select all

extern void  customfunction(physent *d);
I have then added the function in rpg.cpp as (again after the suicide function):

Code: Select all

void customfunction(physent *d)
	{
	  //implementation code to go here
	}
Now I try and call the function in physics.cpp like so:

Code: Select all

game::customfunction(pl)
However when I try and recompile I get the error:

.objs\engine\physics.o:physics.cpp|| undefined reference to `game::customfunction(physent*)'|

I'm guessing I'm not fully understanding the language. Could someone explain what is causing the error?

Cheers,
Denyer

Re: Error Adding Custom Function to Source Code

Posted: June 17th, 2012, 6:56 pm
by Hirato
If that's at the linking phase, the other game modules will need stub implementations of customfunction at the very least.
Alternatively you just just remove them from the list of targets in he "all" virtual target and build only the RPG.

Re: Error Adding Custom Function to Source Code

Posted: June 18th, 2012, 2:45 am
by Denyer
Thanks for the reply,

Hmm, I did think that might be the issue so I tried adding in default implementations into the other game modules, I guess I made a mistake somewhere.

I'll give it another go,

Again thanks for the help Hirato :)