External function help...

Started by
6 comments, last by aBlas 21 years, 2 months ago
I''m having problems getting my files to see functions in other files when compiling on borland. I''m using borland command line compiler 5.5 and I have a function in a file named m_misc.cpp and a prototype for it in a file named m_misc.h and when I include m_misc.h in another header file and try to make a call to the function, I get an external linkage error. If anyone would like to take a look at my code, you can find it compressed as an ace file here. I''m compiling it using the dos command "bcc32 sys_main.cpp". Thanks ahead of time, I hope **Edit** If you are uncomfortable downloading the winace file, any suggestions to fix the problem would be welcome.
Advertisement
you neeed to compile all the source files...
bcc32 sys_main.cpp m_misc.cpp [rest of the args]

-----------------------------
Gamedev for learning.
libGDN for putting it all together.
I don''t know exactly how to do it with Borland, but what you want to do is compile each source file into an object file separately, and then link all of the object files into an executable. The commands you use to compile should look something like this (just replace my made-up compiler switches with the correct ones):

bcc32 -create_object_file sys_main.cpp
bcc32 -create_object_file m_misc.cpp
bcc32 -link_object_files sys_main.obj m_misc.obj
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
That doesn't work either, it gives a bunch of errors about calling a nonfunction in function M_CmdLineArgs(char *) and quits compiling. I'm trying to learn how to create a makefile but have been unsuccessful thus far, and that may help when I finally get it completed.

**Edit**

I'm gonna try what Martee said before I complain anymore... be right back

[edited by - aBlas on January 31, 2003 12:37:12 AM]
Ok I tried that but it gives me the same errors as trying to type "bcc32 sys_main.cpp m_misc.cpp" so it thinks that the function is not a function but it is unless I made some stupid mistake that I haven't found yet. Here is the function copy and pasted, hope it turns out ok.

bool M_CmdLineArgs(char *arg)
{
for(int j = 0; j < argc; j++)
{
if(((argv(j)[0] == '/') || (argv(j)[0] == "-")) && (!strcmp(&argv(j)[1], arg))
{
return true;
}
}
return false;
}

[edited by - aBlas on January 31, 2003 12:42:12 AM]
I think you need to add one more ) to the end of your if statement.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Ahh thanks... you were right but it still refuses to compile with the same nonfunction in function errors. The error is on the same line that that missing parenthesis was, but I've included the file needed for strcmp (string.h) so im not sure what the problem is...

**Edit**

I think the problem narrows down to strcmp not having access to argv and argc from Main... how would I go about making those two variables global constants? Sorry for the newbie questions

[edited by - aBlas on January 31, 2003 12:56:54 AM]
Nevermind, I figured out my extreamly stupid mistake. I feel I should be hit with a very large book right now.

This topic is closed to new replies.

Advertisement