PDA

View Full Version : how to convert this struct to delphi?



noeska
24-02-2008, 08:33 PM
Languages: c++/delphi

During the conversion of the efx extension for openal i come accros a struct that for the moment confuses me.

What is this? Is it a record, or is it a function? Or is it a record to an pointer?



typedef struct _EAXOBSTRUCTIONPROPERTIES
{
long lObstruction;
float flObstructionLFRatio;
} EAXOBSTRUCTIONPROPERTIES, *LPEAXOBSTRUCTIONPROPERTIES;

And most importanty how do i write this in delphi?

This i how i think it should be done, but i am NOT sure.


_EAXOBSTRUCTIONPROPERTIES = record
lObstruction: int64;
flObstruction: single;
end;
LPEAXOBSTRUCTIONPROPERTIES = ^_EAXOBSTRUCTIONPROPERTIES;

Brainer
24-02-2008, 08:38 PM
Yes, I think your version is correct, but I'd do it like this:


_EAXOBSTRUCTIONPROPERTIES = record
lObstruction: int64;
flObstruction: single;
end;
EAXOBSTRUCTIONPROPERTIES = _EAXOBSTRUCTIONPROPERTIES;
LPEAXOBSTRUCTIONPROPERTIES = ^EAXOBSTRUCTIONPROPERTIES;

Similar to what you can find in Windows.pas. ;)

arthurprs
24-02-2008, 09:30 PM
C long = Delphi integer not int64

Brainer
24-02-2008, 09:36 PM
You are right, but I've seen a lot of translations, where long has been treated like Delphi's Int64.

JSoftware
24-02-2008, 11:06 PM
It depends on the processor running the code. Normally long is just 32bit. long long on the other hand is 64.

Also, Don't forget to pack the record :wink: