Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:27:54+00:00 2026-05-27T01:27:54+00:00

I have a unit I wrote in Delphi 7 some time ago, and have

  • 0

I have a unit I wrote in Delphi 7 some time ago, and have just had the fun (pain) of converting to Delphi XE (Unicode).

The Unit works fine after some trouble, I am now trying to make this unit compatible with different Delphi Versions should I ever need to switch IDE back to Delphi 7 whilst updating some other code.

I only have Delphi 7 and Delphi XE, but from what I gather code written in Delphi 1 to Delphi 2007 will compile, but code from Delphi 2009 and above will be Unicode.

…Anyway, in the Unit I am separating the non-unicode and unicode like so:

{$IFDEF VER150} //Delphi 7
// code
{$ELSE IFDEF VER220} //Delphi XE
// code
{$ENDIF}

How do I modify the compiler directive so the rules apply to multi versions? For example something like:

{$IFDEF VER80,  //D1
        VER90,  //D2
        VER100, //D3
        VER120, //D4
        VER130, //D5
        VER140, //D6
        VER150, //D7}

This would then cover all Delphi versions should I distribute the source or .dcu unit.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:27:55+00:00Added an answer on May 27, 2026 at 1:27 am

    I wonder if the simplest approach in this instance is to switch behaviour on the UNICODE conditional. This conditional is defined if and only if you are using a Unicode version of Delphi, i.e. in Delphi 2009 and later. The big advantage of this is that it is future proof—you don’t need to update your code every time a new Delphi is released. What’s more, the conditional switch will be far more readable since it will clearly express the intent.

    The Delphi documentation has an excellent topic listing all the pre-defined conditionals. The full list of version conditionals is also linked from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a macro that I wrote to just help me with my unit
I have a unit test that works fine locally but when uploaded to TeamCity
We have some unit tests running against a SQL server 2000 database using the
I have a method calling localtime that I wrote a unit test for. I
I just discovered that the Delphi TRibbonComboBox doesn't have an item index, and it
I have a case in Delphi such as: Unit A contains class One Unit
I wrote some string extension methods in a VB assembly and am unit testing
I have some business objects written in Delphi with a custom scheme of database
I have a multi-threaded Delphi program creating multiple instance of some classes, and I
I have never wrote a line of cfmodule myself. However, now is the time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.