Link to home
Start Free TrialLog in
Avatar of byungho
byungho

asked on

How can I convert c++ struct to pascal code?

Here is C++ struct code declaration:

      struct HLIST
      {
            char         Index;
            int            No:8 ,  Count:24;
            __int64    Offset;                              
      };


I don't know how can I convert bit declaration;;

Here is my code:

      THLIST = packed record
            Index: BYTE;
                No_Count: Integer;  //   int            No:8 ,  Count:24;
            Offset: Int64
      };

I try to declare whole 32bit data(No 8bit, Count 24bit = Total 32bit) to Integer type!!
Then get No and Count value by bit operation!!

 No = THList.No_Count and $000F;
 Count = THList.No_Count and $FFF0;


Is there any convert way gracefully to access each `No` and `Count` variables in record!!
Avatar of Mike McCracken
Mike McCracken

Actually the record has 2 integer components.  Try

      THLIST = packed record
            Index: BYTE;
                No   :    Integer;
                Count: Integer;  //   int            No:8 ,  Count:24;
            Offset: Int64
      };

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of robert_marquardt
robert_marquardt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of byungho

ASKER

robert!! yes it packed!!  I want to access two variables separately!!

So is it impossible to convert pascal code? -_-;;; It is not easy to use!
The above gives you separate variables, but you will have to copy the 3 byte value to an Integer and also have to sign-extend it yourself. It therefore only helps you for "No". Write some access functions.
Avatar of byungho

ASKER

Thank you for reply~~ I'll try~