Re: What's the big deal with cross-platform?



Hans-Peter Diettrich wrote:

Your concern is binary compatibility, i.e. including alignment. In
some places your article is outdated, newer Delphi versions allow for
closer emulation of some C stuff, e.g. for anonymous unions,

Ok, show me how Delphi does *anonymous* unions. One simple example.

discontiguous enums

http://rvelthuis.de/articles/articles-convert.html#enums

<<
While it may be convenient to translate such enums as Delphi enumerated
types, I recently stumbled over a difference. In C and C++, enumerated
types are often assignment-compatible with normal integral types, like
int or unsigned int. Many function declarations reflect this, and
simply declare parameters expecting such enumerated values as DWORD,
ULONG, or similar, and not of the special enum type expected. In C,
this generally causes no problems. In Delphi, enumerated types are a
type of their own, and can not be assigned to normal integral types or
to other enumerated types, so you would have to cast such enumerated
values to DWORD. You could of course also declare the parameters as the
correct enum type, but this may cause incompatibilities with existing
code, especially if this relies on an older translation.


, or methods for bitfield access

http://rvelthuis.de/articles/articles-convert.html#bitfields

<<
Records with properties

In Delphi 2006 for Win32 (as used in BDS2006 and Turbo Delphi 2006),
records with methods, operators and properties were introduced. This
allows you to define the bitfields as properties and define getter and
setter methods:


Bit values can be translated into enums, with a bit of shifting.

http://rvelthuis.de/articles/articles-convert.html#enums

<<
These should not be translated as enumerated type, not even in Delphi 6
or higher, because most of the time they are used to select bits using
the C equivalent of the bitwise /or/ or /and/ operators. This is
possible with enums in C, but not in Delphi. That is why you should
always convert such values, which typically ? but not always ?
represent powers of 2, as constants.



Sorry, but I don't accept your criticisms until you show me what is
wrong and how it can be done better. Nothing in this article is
outdated at all. I think you should read it a little better before you
jump to conclusions that are not warranted at all.
--
Rudy Velthuis [TeamB] http://www.teamb.com

"Don't stay in bed, unless you can make money in bed."
-- George Burns (1896-1996)
.



Relevant Pages

  • Enum type def
    ... I want to define an enum type, which in delphi would look like: ... Var ... enum TOperator {opPlus, opMinus, opDivide, opMul, opUnaryMinus}; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Kudos to the team!
    ... With all the press on Delphi 2005, we skipped installing ... Installed Delphi 2006 and was amazed that every major complaint ... I already miss the case (enum type) not ...
    (borland.public.delphi.non-technical)
  • Re: How do I stop a TSP written in Delphi crashing on Add Provider?
    ... > You cast mod to a pointer to TCHAR but you declare it a char. ... >> Dim buffer As String ... >> I can successfully use the code above to access a functions in the Delphi ...
    (microsoft.public.win32.programmer.tapi)
  • Re: How do I stop a TSP written in Delphi crashing on Add Provider?
    ... Private Declare Function TSPI_providerUIIdentify Lib "PSTSP.DLL" (ByRef ... I can successfully use the code above to access a functions in the Delphi ... I cannot read it or write to it without experiencing a C Program crash (var ... int, but writing affects only the local copy ...
    (microsoft.public.win32.programmer.tapi)
  • Re: Converting C to Delphi
    ... macro and a million constants. ... Can this be imported into delphi or do I ... > Perform those calculations yourself and declare the constants with the ... One is temp, ...
    (alt.comp.lang.borland-delphi)