Delphi Clinic C++Builder Gate Training & Consultancy Delphi Notes Weblog Dr.Bob's Webshop
Dr.Bob's Kylix Kicks
 Borland C++Builder 4 Introduction
See Also: C++Builder Papers and Columns

Remember my article about C++Builder 3? What was the title again? Yep: The CatchUp Game. Well, I can now reiterate that same route taken some time ago. With a thunderous roar we now have C++Builder 4!
And of course, it won't be long until the book C++Builder 4 Unleashed is available as well.

What's new
This is again a long list of features that is added to this version. What basically happened is that the functionality of C++Builder 4 is brought up to par with Borland Delphi 4! But since we're dealing with C++ here, we also are going to examine some new language features.

Up-to-par
Let's review what Inprise did to get C++Builder up-to-par with Delphi 4:

Project manager
The project manager now supports drag and drop. As with Delphi 4, you can have a program group that contains one or more projects. Options are enabled/disabled per project. A project can be activated by selecting it in the dropdown box or by clicking it and then clicking the Activate button. Relevant menu choices in the menu bar reflect your choice. Items can be copied from one project to another. Removing files from a project do not delete the files on disk, which is a good thing.

ClassExplorer
The ClassExplorer originally comes from Delphi 4 also. You can look at your source in the form of a tree and look at types, variables, functions etcetera on a unit-per-unit basis.

Code Insight
Yes, now we have it. Code Insight was one of our envies! We can turn on code completion, code parameters and code browsing, which lets you go to the declaration of what is highlighted, opening the file if necessary. You might want to use a nifty machine for this however.

Dockable windows
You want to feel like a shipyard boss? Dock, dock, dock. Almost anything in the form of a tool window is dockable. Don't want to dock a window? Hold down the Ctrl-key when you drag a window and it will not dock.

MTS
Inprise added support for Microsoft Transaction Server in the multi-tier support. They also provided a wizard to easily create MTS server objects. Want to know more? Try looking around at the website of Microsoft to get a version of MTS. It is basically a transaction server and remote DCOM object administration tool.

ActiveX
C++Builder 4 now generates code for events for Automation servers as well as simple COM objects. Data-bound ActiveX components now communicate with VCL datasets. Generated ActiveX classes now better integrate with OLE servers, and of course, Inprise added support for MTS objects!

VCL enhancements
Inprise brought the C++Builder 4 VCL up-to-par with Delphi 4. If you have them both started on your computer, try switching around between them while comparing the components on the palette. No difference. Most controls now support drag-and-drop and provide more control over layout. New components have been added to create NT service applications and NT services. You can even have more than one service in a service application!

Y2K support
The VCL now contains the TwoDigitYearCenturyWindow variable that can be set to a pivot year for the StrToDate and DateToStr functions. OK, it is a solution, but you might want to build Y2K-compliant applications in future. There is a registry setting to influence BDE in the same fashion. However, the Locate and Lookup functions are not influenced by this because the date conversion is not done by RTL routines and therefore is out of the hands of Inprise. TDateTimePicker also has a problem as long as you do not apply Internet Explorer Service Pack 1, that has an updated COMCTL32.DLL that fixes the problem.

Dynamic arrays
C++Builder 4 now has dynamic arrays compatible with the Object Pascal dynamic array type.

CORBA
The Enterprise Edition now supports CORBA in two ways. You can use the Type Library Editor to roll your own stuff, or use the wizards to let C++Builder generate source code based on IDL. Since Inprise has a particular method of supporting DCOM and CORBA with the Type Library Editor, IDL generated in that way looks very similar to IDL used for DCOM. Using it will probably lock you into that technique and can give you problems as soon as you want to use the type library on other platforms or development environments that do not support the underlying structure Borland C++Builder uses to get it to work. However, working together with Delphi will work, since that development environment support the same underlying structure.
In other cases, just specify IDL by hand and then use the wizards to set up a CORBA client and or server project. For Delphi that can create a problem, since that development environment cannot yet generate code for handling hand-written IDL. There is a solution called IDL2PAS, but that tool does not cover all IDL constructs and does not preprocess the IDL files.

Client data set enhancements
Client data sets now have more possibilities for filtering, support maintained aggregates, allow object relational fields and make it easier to support flat file database.

Multi-tier support
C++Builder 4 now adds more control over multi-tier applications. You can now support remote databases by using the refresh/resync support added, better control over what is included in data packets and the way that updates are applied. TDataSetProvider provides conflict resolution for datasets. Nested tables provide master-detail relationships between tables. Besides all that it is easier to pass parameters to servers and save custom information in data packets.

Package management
Seen Delphi 4? Now we have it too! Package management makes it very easy to build and install packages in the IDE. Also, the Package Collection Editor is added to C++Builder.

Database enhancements
Now it is possible to modify your data model while building forms or data modules. Besides that, BDE and data access components support new versions of databases, for example Access'97 and Oracle8. What's gone is the Visual Query Builder. It has been replaced by SQL Builder.

Command line tools
C++Builder 4 has new switches for TDUMP, IMPDEF, IMPLIB and COFF2OMF.

Visual C++ 5 conversion tool
Yep. Now we can take a Microsoft Visual C++ 5 project and generate a C++Builder 4 project from it.

Compiler features
The pack pragma's has changed in syntax. The pragmas alignment and check option have been added. Addresses for inline functions are now the same for all modules they occur in.

Namespace syntax change
There is now a difference in namespace use. If you use the headers with the h-extension, the declarations are included in the default namespace. That saves you a using clause to get at the declarations in those headers. If you use the header name without the h-extension, you need to add a using-clause.

Templates
Too much to mention. Basically, the C++ compiler now is up to par with the latest and greatest ISO C++ standard. To mention a few: member template functions and classes, partial specializations, partial ordering rules, template template parameters, friend templates, typename keyword, explicit specialization, overloading of template and non-template functions, explicit instantiation of template members, etcetera, etcetera. Also, the -J switch family has changed.

Bitfields
Now we have bitfields with an arbitrary number of bits in them.

C constructs
Anon structs and anon unions as well as inline are now supported in C. Inline is written as __inline for C. The __inline keyword is also supported in C++.

C++ constructs
The __try keyword is now also supported in C++.

Default alignment
The default alignment is now 8 bytes instead of 4 bytes. VCL is guarded with pragmas to keep it 4 bytes. If you want to use the new alignment, you must recompile or guard the proper stuff with pragmas. Be warned, improper alignment can lead to crashes or funny behaviour.

RTL

New functions
C++Builder 4 adds the snprintf family that lets you specify the maximum number of characters copied. Other than that they are equal in functionality to the sprintf family. Inprise also added a list of IEEE floating point functions, Microsoft compatible thread functions, wide char support functions and multibyte character functions.

STL
Borland C++Builder 4 ships with the Rogue Wave STL version 2.02. It includes a lot of bug fixes and has a couple of extensions to the streams library. They offer additional constructors for streams that use file descriptors. Now you may use pipes for example that could not be opened using the ANSI file handling functions like open() and close(). They also added multithread support. There are however some restrictions in the use of the latest and greatest C++ features.

Headers
Inprise added a very large number of headers, mostly from the platform SDK.

TLS
The size of thread local storage is now unlimited. The dynamic runtime library now uses one TLS slot for an application instead of one slot per PE module. To use this feature you must link against the dynamic RTL. Also, Delphi compiled DLLs use additional TLS slots for threadvars, and MS DLLs use a separate TLS slot.

Upgrading
Upgrading from C++Builder 3 to C++Builder 4 is mostly without problems. However, you might incur some problems due to the new template syntax, the changed handling of header files and the change in default alignment. The additional possibilities are very big however. Most tests I concluded did not give raise to difficulties however.

Conclusion
Borland C++Builder 3 was a tool that could do a lot of things. But C++Builder 4 is even better. In my humble opinion it is worth the upgrade, especially if you're considering to combine it with Borland Delphi 4. These two are a good match and work perfectly together.


This webpage © 2000-2017 by Bob Swart (aka Dr.Bob - www.drbob42.com). All Rights Reserved.