Interesting, one can simply attach a zip file. Did not know this.
Anyway, I linked your sample!
I had to made the following changes.
- Add
#ifdef __cplusplus
extern "C" {
#endif
at the start of MFC5xxx.h and
#ifdef __cplusplus
}
#endif
at the end. C++ mangles the function names, and those functions are accessed (say defined) from C and (used) C++.
- add
#define _UNDERSCORE_
in mcf5xxx.s. You thought right, the C compiler does add an underscore in the front.
- define the function cpu_handle_interrupt.
The code actually calls it, but the definition is missing.
So I added
void cpu_handle_interrupt (int) {
}
at the bottom of mcf5xxx.c. That's definitely not enough for this function to work, but its enough to link :smileywink:
CompilerGuru,
Thanks for the information. Let me summarize to help gain a full understanding in a general sense.
1) A "C" function called within a "CPP" file needs the "extern "C" { }" block defined to prevent name mangling.
2) An "S" (assembly) routine called from within a "C" function needs no special handling in the "C" file.
3) A "C" function referenced from the "S" routine needs the underscore added to match the assembler/linker output.
Is the "extern "C" { }" an ANSI Standard that I should read about? If so where is a good place to acquire the ANSI Standard?
Thanks again for your help.
Mark