Compile delphi 5 code in Delphi 2009

942 views Asked by At

It is possible to work with a Delphi 5 project in the Delphi 2009 IDE by referencing the Delphi 5 version of dcc32?

If so are there any issues to watch out for concerning the way that project settings (search paths, conditional defines etc.) are implemented in 2009?

Edit: Just to clarify I am also upgrading the project to Unicode but will still need to debug and run releases in the old configuration

3

There are 3 answers

0
Bruce McGee On BEST ANSWER

It depends on what you're trying to accomplish and what limitations you are willing to accept.

As far as I know, you can't use the Delphi 2009 IDE to maintain Delphi 5 projects directly. For example, even if you stick to functionality that's common between the two, some properties that are not supported in Delphi 5 are written to your DFMs, causing an error at run time.

I've maintained projects and library code that were written in Delphi 2005/2006/2007 that was also being used in Delphi 6/7. I usually edited and debugged these using the latest IDE. I had separate project files for each target version and made sure they all used the same memory manager. Finally, I had an automated build process and unit tests that would strip incompatible properties out of the DFMs (my own DFM Scrubber), make sure all of the targets always compile and run unit tests, which are also recompiled for each target.

All in all, it's more effort and I wouldn't recommend it unless you have a specific requirement to do so.

0
Warren  P On

You either port your code to Delphi 2009/2010 level (Unicode), or you may as well not install the product.

I suggest you open the project and see where it fails, close the project (without saving anything), find the component versions you need and install them, and once the project opens up in design mode (all components are installed) you can start porting.

Read the Unicode Delphi migration (porting) information available at the website.

Ask your self each time you see PChar, and Char, if it needs to be PAnsiChar, or AnsiChar instead? If you are reading bytes from a disk, a com port, or a network connection, you will need to change from Char to AnsiChar, from PChar to PAnsiChar, otherwise, you might just leave the Char and PChar as they are and they will become Unicode. Always be aware that Char is not a Byte, anymore.

You also must replace explicit references to narrow Win32 API calls with versions without the A (ansi) suffix. Example: CreateFileA might need to become just CreateFile.

W

0
Donnie On

No. That said, it is still Delphi, and assuming you have source or D2009 versions of any custom components it can be modified to compile in Delphi 2009. The layout of the VCL has changed quite a bit since D5, so expect to have to modify your uses clauses and probably rewrite some small chunks here and there, but it is doable.