Pype.Clicker wrote:
so in essence, there would be no difference between a C++ library and a C library? ...
No, and yes. (Hi Pype.
)
In modus operandi, there is no difference between writing a C lib and a C++ lib. Write your code, ommit the int main(), provide the headers (so client code knows what the library does) and the object code (so client code can link).
However, there
are differences.
1) C++ runtime / kernel space. Even if you do not include anything in your C++ (i.e., you do not use the standard lib), the compiler will link in several things that are not available in kernel space unless you implement them. new(), for example (the C++ equivalent of malloc()) can throw an exception if no memory is available; so you either have to make sure your new() implementation does not, or you have to provide exception support.
2) name munging. C++ symbols are significantly different from C symbols. (Symbols, you know, the funny things the linker has to bother with
) In C++, the symbols contain type information, namespace information, and some other bits that make them incomprehensible for C linkage (and, usually, the human reader
). However, in C++ you can
declare something to have plain C linkage ([tt]extern "C"...[/tt]).
The downside of 2) is that you can't export an OO interface with C linkage since you would lose the crucial type information. With skill, care, and experience you can "wrap" a C linkage layer around your C++ library.
Then again, I am not sure I understood justinkr's problem. He wants to write an <iostream> library that uses your ISR's instead of DOS interrupts... that doesn't exactly sound like a linkage problem?