Jump to content
Sign in to follow this  
Fr0sT.Brutal

Compiler capability defines and more

Recommended Posts

Include files for checking compiler versions and capabilities. Useful for developers of libs/components that have to support multiple compilers.

 

https://github.com/Fr0sT-Brutal/Delphi_Compilers

 

Additionally, there are files for checking current compiler settings, some cross-compiler and cross-platform defines and cross-compiler declarations.

  • Like 2

Share this post


Link to post

The general hints in the readme are very valuable (and made me revisit some of my ifdef checks) - apart from that it reminds me a bit of https://xkcd.com/927/

 

Yes, jedi.inc is long and unwieldy at times but it got everything commonly needed - in case it does not - wouldn't it be wiser to add that instead of rolling a new thing?

Apart from that the prefix CAPS is kinda misleading imo - why not go with the HAS_ or SUPPORTS_ prefixes?

 

Oh a note on your comment for bitness checking - the example does not entirely match what you describe, it specifically checks for x64 - so x86 and arm would go in the else.

Bitness checks would be CPU32BITS and CPU64BITS or whats also common to check SizeOf(Pointer) = 4 for 32bit.

Historically the checks are rather for x86 specifically to implement something using asm and then pure pascal in else.

Edited by Stefan Glienke
  • Like 2

Share this post


Link to post
17 minutes ago, Stefan Glienke said:

The general hints in the readme are very valuable (and made me revisit some of my ifdef checks) - apart from that it reminds me a bit of https://xkcd.com/927/

As a former colleague was fond of saying, the nice thing about standards is that we have so many from which to choose.

  • Like 1

Share this post


Link to post
15 hours ago, Stefan Glienke said:

The general hints in the readme are very valuable (and made me revisit some of my ifdef checks) 

I'm glad to help 🙂

15 hours ago, Stefan Glienke said:

Yes, jedi.inc is long and unwieldy at times but it got everything commonly needed - in case it does not - wouldn't it be wiser to add that instead of rolling a new thing?

Well, I've never used JEDI as is right because of its monsterosity. Moreover their basic define system has the critical weakness - it must be updated for every new compiler version; and it's DAMN long while I wanted short and universal solution.

15 hours ago, Stefan Glienke said:

Apart from that the prefix CAPS is kinda misleading imo - why not go with the HAS_ or SUPPORTS_ prefixes?

Caps are compiler capabilities... I don't remember why I called them so. SUPPORTS is longer but acceptable as well, agreed.

15 hours ago, Stefan Glienke said:

Oh a note on your comment for bitness checking - the example does not entirely match what you describe, it specifically checks for x64 - so x86 and arm would go in the else.

Bitness checks would be CPU32BITS and CPU64BITS or whats also common to check SizeOf(Pointer) = 4 for 32bit.

Historically the checks are rather for x86 specifically to implement something using asm and then pure pascal in else.

You're right, that was previous, quite weak, sample. I already changed it to check for 64 and 32 bitness explicitly. Oh and there's another bug indeed - I used "X" letter in defines which means Intel arch. In fact, it was meant to be CPU32/64 (FPC-style) which are defined for Delphi in XPlatformCompat.inc file.

Share this post


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

critical weakness - it must be updated for every new compiler version

No, it's upwards compatible - an unknown version identifies as latest known one including all feature defines

Share this post


Link to post
7 minutes ago, Stefan Glienke said:

No, it's upwards compatible - an unknown version identifies as latest known one including all feature defines

Likely it is. I looked at that file and got lost in these loooong nested defines so won't argue

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
Sign in to follow this  

×