Jump to content
Vincent Parrett

Detecting update versions in defines

Recommended Posts

Anyone know how to detect specific update version in compiler defines.

 

I'm already doing 

 

{$IF CompilerVersion >= 25.0} 

 

but I need to detect compiling under 10.2.2 vs 10.2.3 etc

  • Like 1

Share this post


Link to post

I know of no such option. GExperts reads the version info of several files to get this info at runtime.

  • Like 1

Share this post


Link to post
16 minutes ago, dummzeuch said:

I know of no such option. GExperts reads the version info of several files to get this info at runtime.

I suspected as much.  It's a change in the tools api I needed to detect, which was added in 10.2.2 . In any case I can't have different patch versions installed to compile against anyway so I guess.  

Share this post


Link to post

If such an update introduces a new identifier you can catch that with an {$IF Declared(<something>)}

Share this post


Link to post
6 minutes ago, Uwe Raabe said:

If such an update introduces a new identifier you can catch that with an {$IF Declared(<something>)}

Thanks. I have it working, but it does introduce a positioning issue with the include statement, can only be included after the uses clause and that uses clause must include the unit with the identifier. Not a huge deal in my case but could be a bit of a gotcha if you were using that same include file to ifdef the uses clause itself!

Share this post


Link to post
3 hours ago, Uwe Raabe said:

If such an update introduces a new identifier you can catch that with an {$IF Declared(<something>)}

Wow, at least in 10.3 it works even with class members

{$if not declared(TObject.Create)}
  BOO! // will be ignored
{$endif}

upd

But not this way:

{$if not declared(TObject.Foo)}
  BOO! // will be ignored
{$endif}

Seems this check only works for members that actually exist

Edited by Fr0sT.Brutal
upd

Share this post


Link to post
41 minutes ago, Fr0sT.Brutal said:

Wow, at least in 10.3 it works even with class members

Are you sure? I guess that just boils down to declared(TObject) in both cases.

Share this post


Link to post
1 hour ago, Uwe Raabe said:

Are you sure? I guess that just boils down to declared(TObject) in both cases.

 

1 hour ago, Fr0sT.Brutal said:

upd

But not this way:


{$if not declared(TObject.Foo)}
  BOO! // will be ignored
{$endif}

Seems this check only works for members that actually exist

The path must be fully qualified (includes full unit).

{$IF  declared(System.TObject.Foo)}
 foo
{$ENDIF}

 

  • Like 1

Share this post


Link to post

@Vincent Parrett AFAIK there is no way ! The far thing I could get from dcc32 --version was the CompilerVersion. I also scanned all source files and it appears that none of them declare an update version. So what about writing a simple expert plugin that detects the update version at runtime and defines some macros, and then you can test for those macros at compile time ?

Share this post


Link to post

One option would be to use a pre-build-script to set a compiler define depending on some external criteria.

This could work via an include file that gets modified or maybe by changing the dproj file (not sure this is possible).

Of course this only works for a given project.

Share this post


Link to post

Thanks for the input folks.

 

This has all become a moot point as I realised I can't have 10.2.0/10.2.1/10.2.2/10.2.3 installed at the same time, so it's likely I'll just support the latest patch version for each compiler version.

 

That said, @Uwe Raabe shared (privately) how he handles this (tools api change) in MMX, that will allow people to compile the project with older patch versions themselves if needed. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×