[patch_done] Conditional compiles for Zeos 6 and 7

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

[patch_done] Conditional compiles for Zeos 6 and 7

Post by marsupilami »

Hello,

I am currently using some components with Zeos 6 and would like to also be able to use them with Zeos 7. Unfortunately Some Classes changed the units, where thys reside. So is there a constant defined anywhere do make some conditional compiles for this?
Best regards,

Jan
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

marsupilami,

Hi Jan, nun muß ich sagen, das ich nicht recht verstehe, worauf dein Frage hinausführt..
Can you explain me a little bit more detailed what exactly you are looking for?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Post by marsupilami »

Hello Michael,

I have written components, that make use of the Zeos components. It seems, that I need to know which version of Zeos I am compiling against. Is there any constant to check, wether I compile against Zeos 6 or Zeos 7?

Ich habe einige Komponenten geschrieben, die Zeos benutzen. Es scheint so, daß ich für diese Komponenten wissen muß, gegen welche Zeosversion ich kompiliere. Gibt es eine Konstante, mit der ich Prüfen kann, ob ich gegen Zeos 6 oder Zeos 7 kompiliere?

Example / Beispiel:

Code: Select all

uses Unit1, Unit2,
  {$IF ZEOSVERSION = 6}
    Unit3,
  {$ELSE}
    Unit4,
  {$IFEND}
  Unit5, Unit6;
Best regards,

Jan
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

Hallo Jan,

No actually there is no such conditional define. Can you prepare me a proposal for the Zeos.inc? Something like {$DEFINE ZEOS_VERSION = 700} is that valid? If yes then you can have it tonight....
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Post by marsupilami »

Hello Michael,

originally I was more thinking along the lines of something like
const ZEOS_VERSION = 700;

but then one cannot check wether this is declared at all and so a code like
{$IF ZEOS_VERSION < 700}
will break when an older ZEOS is used.

whereas with your proposal of
{$DEFINE ZEOS_VERSION = 700}
the code
{$IF ZEOS_VERSION < 700}
will not compile at all.

So maybe the best route is something like
{$DEFINE ZEOS_PROVIDES_VERSION}
const ZEOSVERSION=700

because this would allow to check similar to this:

Code: Select all

{$IF DEFINED(ZEOS_PROVIDES_VERSION)}
  //put code for Zeos 7, 8, ... , n here
  {$IF ZEOSVERSION>= 700 and ZEOSVERSION <800}
     //ZEOS-7Code
  {$IFEND}
{$ELSE}
  //here you are on your own, but one might decide to just support Zeos 6...
{$IFEND}
But then - I am not sure, which route to go...
Best regards,

Jan
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

marsupilami,

have to think about it. The scope of a define is global...

Actually i propose to check for ZClasses.pas ZEOS_VERSION = '7.0.0-dev';

What do you think?

Edit: Nope a define scope is only local. So we do discuss about best practice to get a global scope of such a constant, Jan. Proposals?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
marcov
Senior Boarder
Senior Boarder
Posts: 95
Joined: 24.06.2010, 09:17

Post by marcov »

There is none, other than passing it on the commandline (via project or not), or using an includefile.

I wouldn't use components includefiles directly in applications though. It will probably give you more trouble (with paths etc) than the whole "automatic" bit is worth.

Simply have an includefile for your app, and switch it manually from 6 to 7.


A different trick is to define a new unit, e.g. zeosimport, and alias all main components and types there.

So

type
sometype = Otherunit.sometype.

but there are probably more types than you want, and the automatic addition of units by the IDE will conflict
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Post by marsupilami »

Hello Michael,

the ZEOS_VERSION from ZClasses is a start. Now I can check if the value there is in a list of values (6.6.6-stable, 6.6.5-stable, 6.6.4-stable, ...). But for the future I propose to add a second constant in ZClasses.pas like
const ZEOS_VERSION_NUM = 700
or something like that. This would make version dependent unit includes and things like that much more easy. The Delphi folks did something similar with their RTLVersion constant...

@marcov: The problem here is, that this is not project dependent. It depends on which version of Zeos is compiled into the IDE and I want this to be auto detected because most probably I have to use these components with Delphi 6, Delphi XE2 and Lazarus.
Also I think about publishing these components and I prefer to do this kind of thing automatically instead of letting the user deal with it...

Best regards,

Jan
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

marcov,

thank's Marco. So there is no way around to have an include file for this case.

marsupilami,

I think, Mark will implement three new constants like:
ZEOS_MAJOR_VERSION = 7;
ZEOS_MINIOR_VERSION = 0;
ZEOS_RELEASE_VERSION = 1;

I hope he'll find a better place than ZClasses.pas which you have to include.

then you can check the values by:
{$IF defined(ZEOS_MAJOR_VERSION)}
{$IF ZEOS_MAJOR_VERSION = 7}
...
{$IFEND}
{$ELSE}
-> older then 7
{$IFEND}

He or me will post here if it is done..
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

Hello Jan,

Mark added these constants to unit ZClasses and ZConnection:

ZEOS_MAJOR_VERSION = 7;
ZEOS_MINOR_VERSION = 0;
ZEOS_SUB_VERSION = 0;
ZEOS_STATUS = 'dev';

Hope this will help you too.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
marcov
Senior Boarder
Senior Boarder
Posts: 95
Joined: 24.06.2010, 09:17

Post by marcov »

EgonHugeist wrote:marcov,
thank's Marco. So there is no way around to have an include file for this case.
Indeed, so something like the following won't work:
Then you can check the values by:
{$IF defined(ZEOS_MAJOR_VERSION)}
{$IF ZEOS_MAJOR_VERSION = 7}
...
{$IFEND}
{$ELSE}
-> older then 7
{$IFEND}

He or me will post here if it is done..
This will always evaluate to false (the ELSE clause) since the constants won't be defined.

You can't check constants in preprocessor code because preprocessor code is evaluated entirely before the compiler interprets the constants.

Always test such suggestions. There is a reason why includefiles are used everywhere :-)

COMPILER and RTLVERSION are project level constants that are probably passed under the hood to the compiler. (or are truely builtin)
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

marcov,
Always test such suggestions
Eye eye! You are right!
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Locked