Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

C Conversion

Is this correct?

I want to verify that I am converting the "struct SDBAttributeList_t FAR *keyList;" correctly

typedef struct SDBAttributeList_t {
    _Int             count;
    SDBAttrHdr_t    FAR *sdbAttrHdr;
} SDBAttributeList_t;

type PSDBAttributeList_t = ^SDBAttributeList_t;
    SDBAttributeList_t   = record
    count : _Int;
    sdbAttrHdr : PSDBAttrHdr_t ;
end;


typedef struct SDBDeleteObject_t {
    SDBConnectionID_t connID;
    SDBFileType_t   fileType;
    struct SDBAttributeList_t FAR *keyList;
} SDBDeleteObject_t;


type  SDBDeleteObject_t = record
  connID: SDBConnectionID_t;
  fileType: SDBFileType_t;
  keyList: PSDBAttributeList_t;  //IS THIS CORRECT?
end;
0
rbohac
Asked:
rbohac
  • 3
  • 2
1 Solution
 
Russell LibbySoftware Engineer, Advisory Commented:
Yes, that is correct. The "FAR *" on the structure is the same as delphi's

PRecordType = ^RecordType

where

RecordType  = (packed) record
 ...
end;


Regards,
Russell
0
 
CodedKCommented:
I think ur code will work as it is for Delphi 2005 but for Delphi 7 i agree with rllibby.
You may have to get rid of packed.
0
 
Russell LibbySoftware Engineer, Advisory Commented:
In truth, it all depends on what your converting / integrating with (packed record types are pretty much the norm nowadays.) If the record structure is in multiples of 4 (hard to tell with the missing decls above), then it will be a moot point, eg:

type
 TFoo1 = packed record
   f1:    Integer;
   f2:    Pointer;
 end;

type
 TFoo2 = record
   f1:    Integer;
   f2:    Pointer;
 end;

SizeOf(TFoo1) = SizeOf(TFoo2)

---------
Russell
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rbohacAuthor Commented:
I have {$A8} set because of a line above it : #pragma pack(8)

How does this effect this?
0
 
Russell LibbySoftware Engineer, Advisory Commented:

Your alignment should be fine as you have them declared. In this situation you would NOT use the packed statement on the record structs, as then they would become the same as

#pragma pack(1) /* the norm */

Russell

0
 
rbohacAuthor Commented:
Awesome. Thanks again!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now