On 1 Jan 2009 at 20:46, Michael B. Brutman wrote:
I've been working on my TCP/IP stack for three years now. It's in
Borland Turbo C++ 3.0, which is capable of taking OBJs and making a LIB
(library) from them. This is how I was planning to distribute my code
for other people to use.
A question came up today that I can't readily answer. If somebody is
programming using Microsoft languages, will they be able to link against
OBJs or LIBs I provide them? I have no idea if the OBJ or LIB format is
standard and portable across the two vendor toolsets.
If it is portable then I know I have to watch out for things like
parameter ordering. But how does one express the concept of NEAR and
FAR pointers in the different languages? Is there a guide or a cross
reference somewhere? Maybe something buried in compiler docs somewhere?
Object files are compatible; there may been some naming convention
issues (recall that MS uses name "mangling" in C++, but I think that
can be turned off.) The calling sequence is standard C, with
arguments being pushed in reverse order and the caller doing the
cleanup. Pointer handling between languages can be very different.
Here's the big rub as I see it--you'll have to provide the other
people with a copy of the Turbo C++ library routines that you use.
Will there be collisions in names? Almost certainly if the user
you're dealing with is writing in MS C.
Each language has its own calling convention (Turbo Pascal, for
example, pushes arguments on the stack the reverse of Turbo C++ and
expects the called routine to do stack cleanup on exit). BASIC
parameter-passing conventions are very different from, C++,
particularly in the case of strings.
It can be done, but it's not always easy.
Cheers,
Chuck