Subj : Re: Sharing code between BC5.02 and BCB5 To : borland.public.cpp.borlandcpp From : "Dennis Jones" Date : Wed Mar 03 2004 12:06 pm "Ed Mulroy [TeamB]" wrote in message news:40462fef$1@newsgroups.borland.com... > The exported symbol name must exactly match the imported symbol name. The > designer of the linker arranged for it to show you the information for both > in the hopes that it would assist you in deciding how to proceed in > correcting the errors. > > A standalone function not part of a class has the same default calling > conventions in C or C++. The only difference is the name mangling that C++ > uses, a method which is used to implement the C++ ability to have overloaded > functions. > > The correct way to do what you ask is to build the DLL with the BCB compiler > so that the names match and then alter the header files so that they no > longer lie. BCB won't compile the OWL DLL's (and no, I don't want to use OWLNext!), so that's out, but I think I have found the cause of the problem: The original code uses many, many header files to declare structures that are passed as parameters to most of the exported functions. The newer code also uses header files to define those same structures, but the newer header files are in a different directory, and the structure names they declare are different than the originals. Thus, when using 'extern "C"', the C compiler didn't do any parameter type-checking, and because the linker doesn't care about the arguments, it linked everything fine. And because the structure contents always matched exactly, everything ran fine. When I eliminated the 'extern "C"', then name-mangling began to take place, and the differences in the structure names became apparent. Most of the old header files have been modified to simply #include the new header files and then use a typedef to make the names match up, but not all of the old headers have had this done yet, and those seem to be the same structures that are used in the functions that I am having trouble linking. For example: The old BCW code exports a function like this: CoverDlg32(HWND__ *, COVLETTER *, short) And the new BCB code is trying to link a function like this: CoverDlg32(HWND__ *, CoverLetter_s *, short) Even though the strcutures "COVLETTER" and "CoverLetter_s" are identical internally, the names are different, and hence the linker error. I haven't tried it yet, but I think by modifiying the rest of the old headers to #include the new headers and the appropriate typedef's will resolve the problem. - Dennis .