<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
The reason you are getting multiple linker errors about the functions in
your code is because they haven't ben<br>
previously <i>declared</i>. You will have to make header files (*.h) (or
one header file) which contain declarations <br>
of your functions. Include this header file within any source file that
uses a function that is declared within<br>
that header file.<br>
<br>
Example:<br>
<br>
<hr width="100%" size="2">test.c<br>
<br>
int myFunction ( int a )<br>
{<br>
return (a * a);<br>
}<br>
<hr width="100%" size="2"><br>
To use this function in another source file you would have to create a header
file :<br>
<hr width="100%" size="2">test.h<br>
<br>
int myFunction ( int a );<br>
<hr width="100%" size="2"><br>
To use this function within, let's say, main.c you would do:<br>
<br>
<hr width="100%" size="2">main.c<br>
<br>
#include <stdio.h><br>
<b>#include "test.h"</b><br>
<br>
int main ( int argc, char *argv[] )<br>
{<br>
<br>
int num = 2;<br>
int result = myFunction ( num );<br>
<br>
....<br>
<br>
return 0;<br>
}<br>
<hr width="100%" size="2"><br>
<br>
I hope this helps.<br>
<br>
<br>
- Derek<br>
<br>
<br>
<br>
Y&S Geadah wrote:<br>
<blockquote type="cite" cite="mid000801c2811a$47fb9cc0$8400a8c0@sandy">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.2719.2200" name="GENERATOR">
<style></style>
<div><font size="2">I am a new user to the Dec-C++ IDE, with a reasonably
good knowledge of the</font></div>
<div><font size="2">C language, but very poor knowledge of other tools
(linker, debugger, etc...)</font></div>
<div> </div>
<div><font size="2">My problem is as follows:</font></div>
<div><font size="2"> - I have been developing a program in C, with all
the source code (main and </font></div>
<div><font size="2"> functions) in one source file, i.e. my project
consisted of only one file (extension .c)</font></div>
<div> </div>
<div><font size="2"> - as the program grew bigger and bigger, I decided
to move the functions into</font></div>
<div><font size="2"> their separate source files, for ease of editing;I
added their source files (*.c)</font></div>
<div><font size="2"> to the project list</font></div>
<div> </div>
<div><font size="2"> - by doing so, I am getting many compiler and linker
errors (note: some</font></div>
<div><font size="2"> of the function arguments are structures; other
functions access files, </font></div>
<div><font size="2"> i.e. use fopen, fprintf, ... Again, everything
works fine with a single source</font></div>
<div><font size="2"> files, containing main() and all functions)</font> </div>
<div> </div>
<div><font size="2">I must be missing something fundamental in the structure
(due to my lack of</font></div>
<div><font size="2">understanding of how files are linked). Are there any
online information (more</font></div>
<div><font size="2">tutorial-like) on such topics?</font></div>
<div> </div>
<div><font size="2">Any help will be much appreciated. </font></div>
<div> </div>
<div><font size="2">Regards, </font></div>
<div> </div>
<div><font size="2">YG</font></div>
</blockquote>
<br>
<br>
</body>
</html>
|