Vincent Parrett 750 Posted October 25, 2020 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 1 Share this post Link to post
dummzeuch 1505 Posted October 26, 2020 I know of no such option. GExperts reads the version info of several files to get this info at runtime. 1 Share this post Link to post
Vincent Parrett 750 Posted October 26, 2020 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
Uwe Raabe 2057 Posted October 26, 2020 If such an update introduces a new identifier you can catch that with an {$IF Declared(<something>)} Share this post Link to post
Vincent Parrett 750 Posted October 26, 2020 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
Fr0sT.Brutal 900 Posted October 26, 2020 (edited) 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 October 26, 2020 by Fr0sT.Brutal upd Share this post Link to post
Uwe Raabe 2057 Posted October 26, 2020 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
Mahdi Safsafi 225 Posted October 26, 2020 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} 1 Share this post Link to post
Mahdi Safsafi 225 Posted October 26, 2020 @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
dummzeuch 1505 Posted October 26, 2020 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
Vincent Parrett 750 Posted October 26, 2020 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