2

What's the first version of Delphi that has Int8, Int16, Int32, UInt8, UInt16, UInt32 declared in the System unit.

Which VERnnn conditional symbol or RTLVersion value do I need to use for detection?

rene
  • 41,474
  • 78
  • 114
  • 152
Premature Optimization
  • 1,917
  • 1
  • 15
  • 24
  • 1
    I think it must have been very, very recent. They really dragged their feet in giving us usable names for those types. If these names were there in Delphi 2007, I never ran across them. – Joe White Jun 04 '11 at 19:23
  • @David Heffernan, careful, please. That edit was distorting. My primary objective is RTL version #, but "street name" is ok too, since i have table mapping marketing names to versions. "Include" was a call for answering users, because valid response might be too short. – Premature Optimization Jun 04 '11 at 19:51
  • 1
    I've no idea what you are talking about. Street name? The original question just said IntNN which I simply did not understand. – David Heffernan Jun 04 '11 at 19:55
  • 1
    @user I think your comment about the edit should have been directed at Johan. I only change the IntNN/UIntNN to specific versions. – David Heffernan Jun 04 '11 at 20:07
  • @David Heffernan, ah, excuse me, did not notice TWO edits. Your edit was clarifying. "Street names" are coming marketing department and are completely incoherent from the software versioning point of view (eg: Delhi XE, Delphi HUH, Delphi LOLWUT). This trend is best illustrated by usage of `X3` in place of version `13.0`. – Premature Optimization Jun 04 '11 at 20:28
  • @Johan, please read above and dont do such edits. – Premature Optimization Jun 04 '11 at 20:30
  • @Andreas Rejbrand, can you convert your comment to an answer, please? – Premature Optimization Jun 04 '11 at 20:31
  • @user, the OP was confusing I was trying to clear it up. Please don't post such confusing questions :-). – Johan Jun 04 '11 at 20:37
  • 1
    @user759588: And so I have done. – Andreas Rejbrand Jun 04 '11 at 20:39
  • 1
    @user Johan is a high rep user, he is perfectly entitled to make such edits. If you wish to revert then that's your right too. This is a wiki. – David Heffernan Jun 04 '11 at 20:39

2 Answers2

3

I don't know the answer to your question. However, you could avoid needing to know by using code like this in a global include file or a unit that is used by all other units in your code:

{$IF Declared(System.Int8)}
{$ELSE}
type
  Int8   = ShortInt;
  Int16  = SmallInt;
  Int32  = Integer;//or Longint if you prefer
  UInt8  = Byte;
  UInt16 = Word;
  UInt32 = Cardinal;//likewise for Longword
{$IFEND}
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 2
    @David, thanks for this. I hadn't seen `Declared` before, and actually had to copy/paste your code into a project and compile it to believe it worked. :) +1. (BTW, I even added `{$MESSAGE 'Declared worked'}` between the `$IF/$ELSE` to make sure. ) That brings up another question, though - when was `Declared` added? – Ken White Jun 04 '11 at 19:38
  • @Ken White, D6 (check for VER140 or CONDITIONALEXPRESSIONS) – Premature Optimization Jun 04 '11 at 19:53
  • Feature detection instead of version sniffing, good idea, ought to work too. – Premature Optimization Jun 04 '11 at 19:55
  • @Ken certainly present in D6, and I have a feeling that's when it was introduced. – David Heffernan Jun 04 '11 at 20:06
  • I see a flaw, Cardinal is generic type. – Premature Optimization Jun 04 '11 at 20:33
  • 1
    @user And so is Integer. Use Longint and Longword if you wish. For what it's worth, Integer and Cardinal will be 32 bit even in Delphi 64. The declaration above is the taken straight from System.pas. – David Heffernan Jun 04 '11 at 20:37
  • @user, cardinal is an unsigned int32. there's no flaw. – Johan Jun 04 '11 at 20:38
  • @Johan, there is, read up on fundamental and generic types. @David Heffernan, i'd edit that, such personal preference might come out as 16bit Int32 :-) – Premature Optimization Jun 04 '11 at 20:50
  • @user I think we can safely neglect Delphi 1 can't we! Also the $IF won't work. – David Heffernan Jun 04 '11 at 21:04
  • @David Heffernan, why not to use correct types and retain portability? – Premature Optimization Jun 04 '11 at 21:21
  • @user Use Longint and Longword then as I already said. And I say again, the code above comes from System.pas – David Heffernan Jun 04 '11 at 21:27
  • @David Heffernan, that mean what System.pas is not portable (and should not be by Borland compiler design). Should we copypaste code from there to our portable code? (as side note: copypasting might violate product license) – Premature Optimization Jun 04 '11 at 21:34
  • @user, Lazarus/FreePascal uses the same datatypes, what portability issues are you talking about? – Johan Jun 04 '11 at 21:42
  • @user Copyright is fine, it's what is known as *fair use*. I don't know what you mean by portable. But this is all pointless. The main idea is `$IF Declared(...)`. What's to stop you putting whatever you like in the definition of `Int32`? I'm not standing in your way. – David Heffernan Jun 04 '11 at 21:45
  • @Johan, what's the difference between generic and fundamental type? – Premature Optimization Jun 04 '11 at 21:47
  • if you can exclude 16 bit then there is no difference, at the moment! – David Heffernan Jun 04 '11 at 21:52
  • @user that concept does not exist any more in Delphi. integer is 32 bit. Now and forever. You are talking about c(++). – Johan Jun 04 '11 at 21:52
  • @johan I don't think you can say forever. I think the policy is that integer is the same size as a C int on the prevailing platform. That's 32 bits on all known Delphi platforms but it could change in the future. – David Heffernan Jun 04 '11 at 21:55
  • @David, @user, from the horse's mouth: "There are two integer types, NativeInt and NativeUInt, whose size will float between 32-bit and 64-bit depending on platform. They've been around for quite a few releases. No other integer types will change size depending on bitness of the target." see: http://stackoverflow.com/questions/4051603/how-should-i-prepare-my-32-bit-delphi-programs-for-an-eventual-64-bit-compiler/4052431#4052431 – Johan Jun 04 '11 at 22:11
  • @johan that's specifically about upcoming delphi 64 and makes no claims about any other platforms that may be supported in the future – David Heffernan Jun 04 '11 at 22:20
  • @Johan, @David Heffernan, you are abusing low diversity of Pascal implementation which leads to monopoly which cannot follow its own rules. Types concept was reeled by gcc vs. MSVC disagreement on 64-bit generic types, reeking havoc in tiny Delphi encampment (remember, Delphi isnt just VisualStudio lookalike, but also MUST maintain compatibility with C++ Builder) – Premature Optimization Jun 04 '11 at 22:55
  • @David Heffernan, accept my edit then :-P BTW, talking about choosing right types - i have a work-in-progress code which still able to load datafiles created in early 1990 – Premature Optimization Jun 04 '11 at 23:27
2

All I know for sure is that these type aliases are declared in Delphi 2009, and I wouldn't be surprised if this is the version in which they first appeared.

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384