"Picky" Multiple Function Declaration Error 
Author Message
 "Picky" Multiple Function Declaration Error

I'm having a problem that I don't understand.  I'm using gcc 2.96 (g77
actually) on a Linux Mandrake 8.1 system.

I've created a library archive (.a) that contains a number of
functions to allow someone to write their own code and use certain
functions in the library.  One of these functions, call it
ErrorCallBack, is called by other functions in the library if some
sort of error occurs in the calculatios.  The ErrorCallBack function
just prints a message and stops. Now, my intent is to allow the user
to supply their own ErroCallBack function in their own code so that
they can do whatever cleanup, message printing they desire.  The
ErrorCallBack in the archive library is meant to be a default incase
the user does not supply one so that the other functions in the
archive can resolve their calls to ErrorCallBack.

Now the problem I am experiencing is this.  If the ErrorCallBack
function in the archive is placed in a file by itself, compiled and
added to the archive, then when I write something that I link with the
library and supply my own ErrorCallBack function, the compiler does
not complain about multiple declarations of the same function
(ErrorCallBack).  However, if I place the definition of the
ErrorCallBack function to be placed in the archive in one of the other
source files that get added to the archive, then when I link the same
driving code (which has its own ErrorCallBack function) with the
library I get an error message about multiple declarations of
ErrorCallBack and no executable is generated.

I don't understand why it works one time and not the other.  As I
mentioned above this is using the fortran language otherwise I'd be
using function pointers to get the job done although it seems like the
same problem would occur with gcc if one had constructed a similar
setup.



Mon, 14 Feb 2005 21:37:36 GMT  
 "Picky" Multiple Function Declaration Error
when a subroutine or function is compiled with others sub or func in the
same
file the compiler make one file with unseparable objects code. If your
program
call one of the sub or func, all are embedded from the obj file, making
conflicts with same names from other obj files.
Quote:

> I'm having a problem that I don't understand.  I'm using gcc 2.96 (g77
> actually) on a Linux Mandrake 8.1 system.

> I've created a library archive (.a) that contains a number of
> functions to allow someone to write their own code and use certain
> functions in the library.  One of these functions, call it
> ErrorCallBack, is called by other functions in the library if some
> sort of error occurs in the calculatios.  The ErrorCallBack function
> just prints a message and stops. Now, my intent is to allow the user
> to supply their own ErroCallBack function in their own code so that
> they can do whatever cleanup, message printing they desire.  The
> ErrorCallBack in the archive library is meant to be a default incase
> the user does not supply one so that the other functions in the
> archive can resolve their calls to ErrorCallBack.

> Now the problem I am experiencing is this.  If the ErrorCallBack
> function in the archive is placed in a file by itself, compiled and
> added to the archive, then when I write something that I link with the
> library and supply my own ErrorCallBack function, the compiler does
> not complain about multiple declarations of the same function
> (ErrorCallBack).  However, if I place the definition of the
> ErrorCallBack function to be placed in the archive in one of the other
> source files that get added to the archive, then when I link the same
> driving code (which has its own ErrorCallBack function) with the
> library I get an error message about multiple declarations of
> ErrorCallBack and no executable is generated.

> I don't understand why it works one time and not the other.  As I
> mentioned above this is using the Fortran language otherwise I'd be
> using function pointers to get the job done although it seems like the
> same problem would occur with gcc if one had constructed a similar
> setup.



Mon, 14 Feb 2005 22:02:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. g77 linker "multiple definition" errors

2. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

3. Function names and "filter" function

4. "bound error" error# 1132

5. Error with eruby: "Exec format error"

6. error writing "stdout": I/O error

7. errors, "cannot import name", "cannot assign to function"

8. "Interning" objects based on multiple attributes

9. "Interning" objects based on multiple attributes

10. "Smalltalk-Contracts-Multiple-Ohio"

11. "Smalltalk-Contracts-DC-Multiple"

12. "Smalltalk-Contracts-Multiple-Ohio"

 

 
Powered by phpBB® Forum Software