Posts: 59
Threads: 21
Joined: Dec 2012
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?
Posts: 101
Threads: 2
Joined: Sep 2011
hmm.
I don't want to find it for you, look in protos.h.
Posts: 59
Threads: 21
Joined: Dec 2012
01 Feb 13, 12:27AM
(This post was last modified: 01 Feb 13, 12:28AM by Lee.)
Well besides that, if it is prototyped, then I should be able to execute drawequipicons() without any errors right?
When I did this inside of clientgame.cpp, I got an error:
#include <renderhud.cpp>
It said in the Output that this line was skipped and then it gets an error on drawequipicons() since it was never defined.
EDIT: I CTRL+F in protos.h and typed 'drawequip' but it didn't find it in there. Does CTRL+F even work when you search for these things?
Posts: 1,331
Threads: 44
Joined: Jun 2010
In most text editors/IDEs, Ctrl + F will perform a search for text within the currently opened/focused file, not all files you may have a tab open for. This is why I suggested you get a program like AstroGrep in the other thread. It makes it easy for you to search the /src/ directory (all source code files) for certain text/line of code (rather than searching file by file manually with Ctrl + F).
Posts: 59
Threads: 21
Joined: Dec 2012
When I CTRL+F in VS, it has an option to search the entire solution/project. Isn't that the same though? I get the same search results with astrogrep.
Posts: 1,331
Threads: 44
Joined: Jun 2010
01 Feb 13, 12:52AM
(This post was last modified: 01 Feb 13, 12:52AM by Bukz.)
Not too sure about the VS option, sounds like it might/should work but I've never used it myself so I can't confirm. Maybe it only searches all currently open files in the project? (meaning you would have to open all source files for the project in the IDE then do it to get the same effect as an AstroGrep search)
Posts: 101
Threads: 2
Joined: Sep 2011
(01 Feb 13, 12:27AM)Lee Wrote: #include <renderhud.cpp>
?
(01 Feb 13, 12:27AM)Lee Wrote: EDIT: I CTRL+F in protos.h and typed 'drawequip' but it didn't find it in there. Does CTRL+F even work when you search for these things?
It becuse it is not defined there.
add "extern void drawequipicons(playerent *p);" in protos.h
or you can put it before use the function in clientgame.cpp.
Posts: 756
Threads: 53
Joined: Nov 2011
02 Feb 13, 05:50AM
(This post was last modified: 02 Feb 13, 05:54AM by Felix-The-Ghost.)
(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.