Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
APIs from QB64PE and parameters defined As Any and unions of types ?
#16
(06-06-2024, 03:15 AM)madscijr Wrote: I don't see any of the UNIONed type being hidden in _OFFSET, or any "padding" or MEMGET or any of that stuff happening to access the members of that type. 

I don't see any of that funny stuff, but it still works. How? Why?
Well that has a lot to do with what you're trying to do with these APIs. The APIs can return any of RAWMOUSE, RAWHID, and RAWKEYBOARD responses, that's the purpose of the union. If you only care about the RAWMOUSE ones (that's the case for the program you posted), then you can ignore the `union` and just pretend it's a `RAWMOUSE` struct (since that's the only one of the union members you would use anyway). If you want to be able to process all three of RAWMOUSE, RAWHID, and RAWKEYBOARD then the union issues come into play.

Also, the code does having padding inserted, that's the `Aiignment` members in the TYPEs `RAWINPUTDEVICELIST`, `PAINTSTRUCT`, and `RAWMOUSE` have padding added (though I'm not entirely sure `RAWMOUSE` is correct, I think that padding is also needed for 32-bit).

(06-06-2024, 01:56 PM)bplus Wrote: so is a union different than math / logic version of the name? ie a set with no repeating elements
Yes, they're not related Big Grin
Reply


Messages In This Thread
RE: APIs from QB64PE and parameters defined As Any and unions of types ? - by DSMan195276 - 06-06-2024, 02:09 PM



Users browsing this thread: 6 Guest(s)