Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++Builder error compiling - constant expression expected - TZDB requires at least Delphi XE to compile! #37

Open
jaridmo opened this issue Feb 11, 2021 · 12 comments
Assignees
Labels

Comments

@jaridmo
Copy link

jaridmo commented Feb 11, 2021

I am using RadStudio 10.3.3 (C++ Builder) to compile TZDB.pas and use, but I get an error on the following:

40 {$IF DECLARED(CompilerVersion)}
41 {$IF CompilerVersion >= 22} // Delphi XE +
42 {$DEFINE TZDB_SUPPORTED_COMPILER}
43 {$DEFINE DELPHI}
44 {$IFEND}
45 {$ENDIF}

The errors:
[Pascal Error] TZDB.pas(41,32): E2026 Constant Expression expected
[Pascal Error] TZDB.pas(50,4): E1054 TZDB requires at least Delphi XE or FreePascal 3.0 to compile!
[Pascal Error] TZDB.pas(69,5): F2613 Unit 'FGL' not found.

I don't know if this is a problem in RadStudio 10.3.3 or if it is a problem with the C++ Builder side, but I can simply comment out the lines of code 40,41,44,45 and compile no problem. But I don't like doing this because whenever I update the source it will be a problem.

Any ideas?

@pavkam
Copy link
Owner

pavkam commented Dec 24, 2021

Hi @jaridmo -- it is outside my scope to deal with C++Builder. But if you provide a working patch I will gladly accept it.

@pavkam pavkam self-assigned this Dec 24, 2021
@pavkam pavkam added the wontfix label Dec 24, 2021
@DieFinsternis
Copy link

For more information: I ran into the same issue today using Delphi 11.
image

I was able to resolve this simply by moving the unit name before the compiler directives.

@rgomezc
Copy link

rgomezc commented Aug 26, 2024

Another victim here of this. As @DieFinsternis mentioned, moving the unit TZDB; line just below the copyright comments and before that $IFDEFs makes the error go away. This was with Delphi 12.1

@pavkam pavkam closed this as completed Mar 27, 2025
@pavkam pavkam reopened this Mar 27, 2025
@pavkam
Copy link
Owner

pavkam commented Mar 27, 2025

Unless anyone else pitches in this won't get done.

@pavkam pavkam closed this as completed Mar 27, 2025
@rgomezc
Copy link

rgomezc commented Mar 27, 2025

Hello @pavkam - as far as I recall, the fix is quite simply. Or is this unit automatically generated by some tool or something? I can certainly create a patch with this change, but maybe I am not getting the whole issue here?

@pavkam
Copy link
Owner

pavkam commented Mar 27, 2025

The description mentions commenting some lines out (those are needed for compatibility with Delphi versions) and I can't do that. Also I don't have a Delphi/C++ builder ATM so I can't make a fix that I would be able to test. If you can send me a patch that doesn't involve disabling those directives, (maybe another IFDEF required?) I will be glad to push it in.

@zedxxx
Copy link

zedxxx commented Mar 27, 2025

If I understand correctly, you just need to swap these two lines:
Image
https://github.com/pavkam/tzdb/blob/master/src/TZDBPK/TZDB.pas#L32

@rgomezc
Copy link

rgomezc commented Mar 27, 2025

I can compile correctly with C++Builder 12.2 with just this change:

--- "a/.\\TZDB.pas"
+++ "b/.\\TZDB.fix.pas"
@@ -25,6 +25,8 @@
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *)

+unit TZDB;
+
 {$IFDEF FPC}
   {$IFDEF VER3} // FPC 3.x
     {$MODE DELPHI}
@@ -50,8 +52,6 @@
   {$MESSAGE ERROR 'TZDB requires at least Delphi XE or FreePascal 3.0 to compile!'}
 {$ENDIF}

-unit TZDB;
-
 interface
 uses
 {$IFDEF DELPHI}

@zedxxx
Copy link

zedxxx commented Mar 27, 2025

I’d also strongly recommend always placing all {$DEFINE} directives and {$INCLUDE} statements after the unit name declaration in all units. This ensures better code organization, improves readability, and helps avoid potential compilation issues.

@pavkam pavkam reopened this Mar 27, 2025
@pavkam
Copy link
Owner

pavkam commented Mar 27, 2025

dfb781e should fix it, if you can double check

@rgomezc
Copy link

rgomezc commented Mar 27, 2025

I was able to compile the dist/TZDB.pas from that commit without issues here.

@pavkam
Copy link
Owner

pavkam commented Mar 27, 2025

Thanks @rgomezc and @zedxxx for the input.

@pavkam pavkam added bug and removed wontfix labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants