Class Pointer Size in C++Blitz3D Forums/Blitz3D Userlibs/Class Pointer Size in C++
| Hi. What is the size in bytes that a class pointer in c++ has?.|
Having a class named KuRiClass in a Dll.
Can i store the pointer in a blitz3d variable (return instance1) then later pass it to a function in the Dll.
The only problem i see here is that the pointer could be destroyed after the function if it is not a global variable?
| Sorry, using SizeOf i can see it is 4 bytes.|
So i can use pointers in a Dll in this way:
/* IN C++ */
KURI_API long _stdcall myfunction()
And later pass this value to the dll...
| here something for you to note kurix, yes a pointer is 4bytes but if you plan on using the dll with blitz heres a trick.|
/* in c++ */
KURI_API class1* _stdcall myfunction()
; in blitz decl file
the idea is not to run a conversion like "return long(instance1) " just just return the pointer itself because its an integer. what this does is speed up the function. when the pointer is returned to blitz its returned as an integer. just pass the same integer to any other function to the dll and make sure the dll recieves the integer as a pointer.
do you understand?
| Yes, you are right. I noticed later, because i thought it was a compiler error, but i forgot to change the returning value of the function in c++.|
| no problem, you should implement this trick to allow kode to take a bank for 3floats when users need to get data from kode so they wont have to make three function calls to get the position of a physics object. |
| Taking Note...|