Announcement

Collapse
No announcement yet.

Help with overlaid structures C++ to PB please

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

  • Help with overlaid structures C++ to PB please

    I know this is a newbie question but it is not something I have encountered before in my limited programming experience!

    I have the following structure in C++ and need to define the equivalent TYPE in PB.

    Code:
    typedef struct _TESTSTRUCT{
    ULONG        field1;
    ULONG        field2;
    
         union {
              struct {                    
                  BOOL    field3;    
              } Check;
    
              struct {                    
                   ULONG    field4;
                   ULONG    field5;        
                   LONG    field6;
                   BOOL    field7;        
                   BOOL    field8;    
              } GetInfo;
         } Parameters;
    } TESTSTRUCT;
    So there is a main TYPE "TESTSTRUCT" that contains two other TYPEs "Check" and "GetInfo". But what is the syntax to correctly implement this in PB (I am using PBCC 6.03)?

    Thanks
    Robin

  • #2
    Code:
    TYPE TESTSTRUCT_Check
       field3 AS LONG
    END TYPE
    
    TYPE TESTSTRUCT_GetInfo
       field4 AS DWORD
       field5 AS DWORD
       field6 AS LONG
       field7 AS LONG
       field8 AS LONG
    END TYPE
    
    UNION TESTSTRUCT_Parameters
       Check AS TESTSTRUCT_Check
       GetInfo AS TESTSTRUCT_GetInfo
    END UNION
    
    TYPE TESTSTRUCT
       field1 AS DWORD
       field2 AS DWORD
       Parameters AS TESTSTRUCT_Parameters
    END TYPE
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Thank you José.

      Comment

      Working...
      X