?
Solved

C Conversion

Posted on 2005-03-28
2
Medium Priority
?
230 Views
Last Modified: 2010-04-05
I am going through and doing a .h to delphi conversion so I an use a 3rd party dll.

I'm trying to figure out how to properly convert the following struct. The problem is that there is a data field after the union.. I'm not exactly sure how to do this in Delphi.

typedef struct
{
      ACSEventHeader_t      eventHeader;
      union
      {
            ACSUnsolicitedEvent            acsUnsolicited;
            ACSConfirmationEvent      acsConfirmation;
            CSTARequestEvent            cstaRequest;
            CSTAUnsolicitedEvent      cstaUnsolicited;
            CSTAConfirmationEvent      cstaConfirmation;
            CSTAEventReport                  cstaEventReport;
      } event;
      char      heap[CSTA_MAX_HEAP];
} CSTAEvent_t;

What I have so far:

type CSTAEvent_t = record
  eventHeader : ACSEventHeader_t;
  case Integer of
    0 : (acsUnsolicited: ACSUnsolicitedEvent);
    1 : (acsConfirmation: ACSConfirmationEvent);
    2 : (cstaRequest: CSTARequestEvent);
    3 : (cstaUnsolicited: CSTAUnsolicitedEvent);
    4 : (cstaConfirmation: CSTAConfirmationEvent);
    5 : (cstaEventReport: CSTAEventReport);
  end;

  //How do I add heap : array[1..CSTA_MAX_HEAP] of char;
0
Comment
Question by:rbohac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 200 total points
ID: 13646870

Just make the union its own record structure

type
  CSTAEvent_t       =   record
     eventHeader:   ACSEventHeader_t;
     event: record case Integer of
        0  : (acsUnsolicited:   ACSUnsolicitedEvent);
        1  : (acsConfirmation:  ACSConfirmationEvent);
        2  : (cstaRequest:      CSTARequestEvent);
        3  : (cstaUnsolicited:  CSTAUnsolicitedEvent);
        4  : (cstaConfirmation: CSTAConfirmationEvent);
        5  : (cstaEventReport:  CSTAEventReport);
     end;
     heap:          Array [0..Pred(CSTA_MAX_HEAP)] of Char;
  end;


Regards,
Russell
0
 
LVL 6

Author Comment

by:rbohac
ID: 13653433
Excellent. Thank you!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question