[PB4.50 x86 Beta 1] different types in StructureUnion

Just starting out? Need help? Post your questions and find answers here.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

[PB4.50 x86 Beta 1] different types in StructureUnion

Post by mpz »

Hi,

i use different types in StructurUnions for DX9, but this works no more. Here comes an example from the help file. Any solution for it or other kind of structure type for that ?

Code: Select all

  Structure Type
    Name$
    StructureUnion
      Long.l      ; Jedes Feld (Long, Float und String) befinden sich
      Float.f     ; an derselben Stelle im Speicher.
      String.s    ;
    EndStructureUnion
  EndStructure
best regards,
Michael
Working on - MP3D Library - PB 5.73 version ready for download
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB4.50 x86 Beta 1] different types in StructureUnion

Post by Fred »

Use a pointer for the string. This kind of structure could produce massive leak.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: [PB4.50 x86 Beta 1] different types in StructureUnion

Post by mpz »

Hello Fred,

i have a DX8 Structure DIACTION for my IDirectInputDevice8 (for my DX9 lib with forcefeedback Joystick an so on)

Code: Select all

typedef struct _DIACTION {
    UINT_PTR    uAppData;
    DWORD       dwSemantic;
    DWORD       dwFlags;
    union {
        LPCTSTR lptszActionName;
        UINT    uResIdString;
    };
    GUID        guidInstance;
    DWORD       dwObjID;
    DWORD       dwHow;
} DIACTION, *LPDIACTION;
 
typedef const DIACTION *LPCDIACTION;
and the PB translation was :
PB Structure

Code: Select all

  Structure DIACTION
    uAppData.l
    dwSemantic.l
    dwFlags.l
    StructureUnion
      *lptszActionName.l ;unicode?
      uResIdString.l
    EndStructureUnion
    uidInstance.GUID
    dwObjID.l
    dwHow.l
  EndStructure

but this works anymore. You say i can only use Pointer in the StructureUnion ?

How can i mak a working PB translation of the DIACTION Structure? Thanks for your help...

best regards
Michael
Last edited by mpz on Fri Apr 02, 2010 10:00 am, edited 1 time in total.
Working on - MP3D Library - PB 5.73 version ready for download
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB4.50 x86 Beta 1] different types in StructureUnion

Post by Fred »

Your new structure looks correct. Use PeekS() get the string content:

Code: Select all

PeekS(YourStruct\*lptszActionName)
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Re: [PB4.50 x86 Beta 1] different types in StructureUnion

Post by Xombie »

Does the pointer in structure thing only work in 4.50 and not 4.41?
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [PB4.50 x86 Beta 1] different types in StructureUnion

Post by Demivec »

Xombie wrote:Does the pointer in structure thing only work in 4.50 and not 4.41?
No it has worked at least as far back as v4.

The example Fred gave contained a typo, it should have left off the '*' when it was used.

Code: Select all

PeekS(YourStruct\lptszActionName)
The '*' is used in the structure when defining it but is left off when referencing the structure element.
Post Reply