Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Pascal Packages

Status
Not open for further replies.

NewBorlandUser

Programmer
Feb 7, 2005
3
US
I'm a new user of Borland's C++ Builder 6 and have inherited some legacy code that includes a call to the function AnsiToNative(). I located this function in CBuilder/Source/vcl/dbtables.pas. So, I added that file to my project and when I built the project, Builder did create the file dbtables.hpp (although it already seemed to exist anyway) along with an object file for dbtables. The header file that was created gave the exact function prototype which I declared as extern in my own files that make the call to AnsiToNative(). Also, I included the dbtables.hpp file in my files so they could find the AnsiToNative() definition.

Well, the result was that my build had a couple different errors. One was an E2040 error in DB.hpp - a file that is used by Borland's dbtables.hpp - the error says "Declaration terminated incorrectly" and the line it flagged with the error didn't seem to be incorrect in any way - it looked just like other lines that had no problem.

The second error was that any of the actual calls to AnsiToNative() resulted in an error which stated there was an ambiguity between the extern declaration at the head of my file and the places where the calls to AnsiToNative() were made.

So, does anyone have any idea as to the procedure of how to correctly use such a function that comes from Borland's object Pascal files?

Thanks in advance for any help anyone can provide on this issue.
 
With all the native Delphi files in BCB it's usually just a matter of calling the function and BCB does the rest.

I suspect that something else is causing the problem and these functions are just where Borland stops. Just out of curiosity, what version of BCB compiled the original program?



James P. Cottingham
-----------------------------------------
To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.
 
Thanks for the thoughts. Yes, I agree - it seems that it should be straight-forward in that one is supposed to be able to simply make the calls and let BCB take care of things. Since I just installed BCB, maybe there is some sort of setup issue, but I haven't yet been able to determine what could be the cause.

The code was originally developed using a BCB version 4.

Thanks again.
 
The problem may stem from the way BCB4 and BCB6 store resources. Somewhere on your computer is a list of changes between the older BCC and the current. On my machine it is Programs->Borland C++->Help->What's New in C++Builder. Open this help file and in the contents is a "book" named Upgrading to C++Builder 6. In this is a section named "Upgrading Projects from previous releases."

See if that gives some help.

James P. Cottingham
-----------------------------------------
To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.
 
Thanks for the further suggestions. However, I was able to get some support from Borland that cleared up the problem. Here's what I had to do:

1) Remove the extern declaration of AnsiToNative() that I had placed in the file using that function. I had added this after compiling burped on not knowing about the AnsiToNative() function. Also, it has been a practice used frequently in the past to include such declarations (to indicate a function is coming from an external source), but apparently not a good idea here for some reason - perhaps having to do with naming ambiguities that arise in going from Pascal to C/C++.

2) Include the right files in the right place (like DB.hpp and DBTables.hpp in our main header file).

3) On the tab in the Project/Options dialogue that is used for specifying directory paths, I removed any path information to CBuilder/Source/vcl. The include paths now simply point to the CBuilder/include and CBuilder/include/vcl directories, while the library paths simply point to the CBuilder/lib/obj and CBuilder/lib directories.

4) Remove dbtables.pas from the project, which I had added according to what I had read on the Internet. This was causing Borland to rebuild files in the CBuilder/Source/vcl directory. When this was done and when I had my include path pointing here, CBuilder would choke in the file DB.hpp - saying there was an incorrect termination on a certain line. It still bothers me that the compiler was stumbling on a file that it was creating - don't know if this will cause any problems in the future or not.

So, that was it. The project now builds. About time!

Thanks again very much for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top