functions between cpp's
#8
(31 Jan 13, 11:44PM)Lee Wrote: I'm trying to use the drawequipicons() function that is in the renderhud.cpp in the dokill() function that is inside of the clientgame.cpp

I read that to use functions defined in another cpp, I need to prototype them in a header (.h) file and then #include it in my clientgame.cpp.

I'm not quite sure if drawequipicons() is prototyped in a header or not, how do I find that out?

In the clientgame.cpp file on a line before doKill() add this:
void drawequipicons(playerent *p);

If you put it immediately before it will look like this:

void drawequipicons(playerent *p);

void dokill(playerent *pl, playerent *act, bool gib, int gun)

That bit of code is what is known as the prototype that you mentioned. In this case it lets the following code know that function is defined elsewhere.

@Jpablon: Functions in C++ have external linkage by default.
Thanks given by:


Messages In This Thread
functions between cpp's - by Lee - 31 Jan 13, 11:44PM
RE: functions between cpp's - by Jpablon - 01 Feb 13, 12:05AM
RE: functions between cpp's - by Lee - 01 Feb 13, 12:27AM
RE: functions between cpp's - by Jpablon - 01 Feb 13, 01:13AM
RE: functions between cpp's - by Bukz - 01 Feb 13, 12:32AM
RE: functions between cpp's - by Lee - 01 Feb 13, 12:43AM
RE: functions between cpp's - by Bukz - 01 Feb 13, 12:52AM
RE: functions between cpp's - by Felix-The-Ghost - 02 Feb 13, 05:50AM