Announcement

Collapse
No announcement yet.

Help converting this C structure?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • C.M. Rouleau
    replied
    Thanks a bunch, Kev.

    ------------------

    Leave a comment:


  • Kev Peel
    replied
    I believe this should be an exact translation. There are three different structures, 2 TYPEs and a UNION, two of which are combined into the parent structure. Structure alignment depends on the C compiler or MAKEFILE setting, in PB the default alignment is BYTE (1). You should verify this is correct before attempting to use the translated structure.

    Code:
    Type flags ' 32-bits total size.
         scalar_flag As Bit * 1 In Dword
         flag1 As Bit * 1
         flag2 As Bit * 1
         flag3 As Bit * 1
         flag4 As Bit * 1
         flag5 As Bit * 1
         flag6 As Bit * 1
         flag7 As Bit * 1
         private_data_flag As Bit * 1
         flag8 As Bit * 1
         flag9 As Bit * 1
         flag10 As Bit * 1
         flag11 As Bit * 4
         flag12 As Bit * 8
         flag13 As Bit * 8
    End Type
     
    Union number_array
         pdata As Dword
         pimag_data As Dword
         reserved5 As Dword
         reserved6(0 To 2) As Long
    End Union
     
    Type mxArray_tag
         reserved As Dword
         reserved1(0 To 1) As Long
         reserved2 As Dword
         number_of_dims As Long
         reserved3 As Dword
         flags
         reserved4(0 To 1) As Dword
         number_array
    End Type

    * Edited to add spacing.

    ------------------
    kgpsoftware.com - Downloads
    kgpsoftware.com - Development and Consulting



    [This message has been edited by Kev Peel (edited July 16, 2007).]

    Leave a comment:


  • C.M. Rouleau
    started a topic Help converting this C structure?

    Help converting this C structure?



    Code:
    struct mxArray_tag {
        void    *reserved;
        int      reserved1[2];
        void    *reserved2;
        int      number_of_dims;
        unsigned int reserved3;
        struct {
            unsigned int    scalar_flag : 1;
            unsigned int    flag1 : 1; 
            unsigned int    flag2 : 1;
            unsigned int    flag3 : 1;
            unsigned int    flag4 : 1;
            unsigned int    flag5 : 1;
            unsigned int    flag6 : 1;
            unsigned int    flag7 : 1;
            unsigned int    private_data_flag : 1;
            unsigned int    flag8 : 1;
            unsigned int    flag9 : 1;
            unsigned int    flag10 : 1;
            unsigned int    flag11 : 4;
            unsigned int    flag12 : 8;
            unsigned int    flag13 : 8;
        }   flags;
        unsigned int reserved4[2];
        union {
            struct {
                void  *pdata;
                void  *pimag_data;
                void  *reserved5;
                int    reserved6[3];
            }   number_array;
        }   data;
    };
    ------------------
Working...
X