Re: What's the big deal with cross-platform?
- From: "Rudy Velthuis [TeamB]" <newsgroups@xxxxxxxxxxxx>
- Date: Sun, 27 Jan 2008 17:34:09 +0100
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)
.
- Follow-Ups:
- Re: What's the big deal with cross-platform?
- From: Hans-Peter Diettrich
- Re: What's the big deal with cross-platform?
- From: Q Correll
- Re: What's the big deal with cross-platform?
- References:
- What's the big deal with cross-platform?
- From: Scout
- Re: What's the big deal with cross-platform?
- From: Maël Hörz
- Re: What's the big deal with cross-platform?
- From: Nathaniel L. Walker
- Re: What's the big deal with cross-platform?
- From: Maël Hörz
- Re: What's the big deal with cross-platform?
- From: Nathaniel L. Walker
- Re: What's the big deal with cross-platform?
- From: Rudy Velthuis [TeamB]
- Re: What's the big deal with cross-platform?
- From: Gil
- Re: What's the big deal with cross-platform?
- From: Rudy Velthuis [TeamB]
- Re: What's the big deal with cross-platform?
- From: Adem
- Re: What's the big deal with cross-platform?
- From: Rudy Velthuis [TeamB]
- Re: What's the big deal with cross-platform?
- From: Adem
- Re: What's the big deal with cross-platform?
- From: Martin Harvey
- Re: What's the big deal with cross-platform?
- From: Rudy Velthuis [TeamB]
- Re: What's the big deal with cross-platform?
- From: Kostya
- Re: What's the big deal with cross-platform?
- From: Gil
- Re: What's the big deal with cross-platform?
- From: Kostya
- Re: What's the big deal with cross-platform?
- From: Rudy Velthuis [TeamB]
- Re: What's the big deal with cross-platform?
- From: Hans-Peter Diettrich
- Re: What's the big deal with cross-platform?
- From: Rudy Velthuis [TeamB]
- Re: What's the big deal with cross-platform?
- From: Hans-Peter Diettrich
- What's the big deal with cross-platform?
- Prev by Date: Re: Codegear-Please bring back C# ( for Delphi's sake )
- Next by Date: Re: What's the big deal with cross-platform?
- Previous by thread: Re: What's the big deal with cross-platform?
- Next by thread: Re: What's the big deal with cross-platform?
- Index(es):
Relevant Pages
|