Mail Archives: djgpp/1997/12/09/16:05:10
On Mon, 8 Dec 1997 22:35:51 +0000, Caroline Langensiepen
<caroline AT timehigh DOT demon DOT co DOT uk> wrote:
> extern void SVAsyncProtISR(void);
[...]
> 4. Trying to be too clever, I changed the extern reference to
> extern SVAsyncProtISR;
I guess that makes SVAsyncProtISR an int...
> This keeps ld happy, all refs are resolved, but the code crashes with
> protection error, suggesting I've probably not got the right ref to the
> ISR address!
Linking C and C++ modules gives unresolved externals because of the
name-mangling that is done for C++ function names. Remember that in C++
you can have two or more overloaded functions, i.e. functions with the
same name but different parameters. So to avoid name clashes in the
linking process, the compiler names the function(int) "_function__Fi"
and the function(char*) "_function__Fpc". A C function() with or without
any parameters will always be named "_function" by the compiler.
To resolve these problems, surround your C headers with
#ifdef __cplusplus
extern "C" {
#endif
[your prototypes go here]
#ifdef __cplusplus
}
#endif
This makes that the compiler tell the linker that it has to search for a
_SVAsyncProtISR, not a _SVAsyncProtISR__Fi or whatever.
Regards...
Michael
- Raw text -