Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
APIs from QB64PE and parameters defined As Any and unions of types ?
#5
(05-30-2024, 09:02 PM)Kernelpanic Wrote: A "union{}" is a mixed type in C. It is comparable to a *)"struct{}" in C with the difference that all variables share the same memory space; the memory space is determined by the compiler based on the longest variable.
*)A C-struct{} is comparable to Type ... End Type in Basic.
...
The "As Any" command in Visual Basic is used to remove the parameter type check when passing parameters. Simply put, it is a hint to the programmer that there is a type difference.

Thanks for explaining... I had some followup questions but I think DSMan195276 answered those...

(05-30-2024, 09:55 PM)DSMan195276 Wrote: I'm pretty sure in this context the `ByRef pData As Any` is just their way of expressing the `void *` type in C. That itself more or less just means it's a pointer to data but the type of data is not specified. As far as QB64 is concerned, you'd just replace it with a ByVal _OFFSET.

KernelPanic explained the Union thing, I'd say in practice what you'll need to do in QB64 is use a memory buffer and copy the data into variables of the right kind based on the dwType entry, so a fair amount more annoying (since QB64 doesn't have actual unions to use). I'd probably just use `_MEMNEW()` to create a memory block of the right size and pass that in as `pData`. Then you can use `_MEMGET` to copy the union section into separate variables of the proper TYPE after checking the `dwType` value, and go from there.

Thank you, that's probably what I need. I'll give those a try!

Thanks again to you both, I was feeling dead in the water for a bit!

(05-30-2024, 10:14 PM)SpriggsySpriggs Wrote: Check the code in that "GPT just rewrote my code" thread. The code there handles MEM for any type.
Perfect... Thanks Spriggsy
Reply


Messages In This Thread
RE: APIs from QB64PE and parameters defined As Any and unions of types ? - by madscijr - 05-30-2024, 10:16 PM



Users browsing this thread: 5 Guest(s)