06-20-2005 02:56 PM
06-20-2005 03:08 PM
@lou 83 wrote:
I'm writing a dll wrapper for rendering library functions. Some of these functions create pointers to class instances and other functions take those pointers as input. I just need to be able to get the pointer value of an instance from a dll into LabVIEW so that I can pass it to the next dll call. I do not intend to use the pointer in LabVIEW. My understanding is that I can simply pass the pointer by value into LabVIEW as a U32 or I32 (not sure which one), then pass that value into the next dll call. However, I always get 0.
My dll function which should pass the pointer value to LabVIEW looks something like this:
_declspec(dllexport) void function (vtkRenderWindow *renWin)
{
renWin = vtkRenderWindow::New(); //creates new instance of type vtkRenderWindow
}
What am I doing wrong?
Thank you in advance,
Louis Ferreira
06-20-2005 09:07 PM
@rolfk wrote:
You should pass the value as int32 as you have found (I prefer uInt32 for pointers but that is mostly cosmetic) but as a pointer (by reference) instead. A C function can not return a value to the caller in a variable which is not declared and implemented by reference.
Rolf Kalbermatter
06-21-2005 01:30 AM
@m3nth wrote:
@rolfk wrote:
You should pass the value as int32 as you have found (I prefer uInt32 for pointers but that is mostly cosmetic) but as a pointer (by reference) instead. A C function can not return a value to the caller in a variable which is not declared and implemented by reference.
Rolf Kalbermatter
On the second point (that a C function cannot return a value to the caller not declared & implemented by reference)... is the original source code listed above correct? It looks right to me (not that that means anything)--are you saying that it's one of the properties in the LabVIEW window where the DLL options are set to pass either a value or a pointer to a value? Or are you saying that the source code above is incorrect?
I pulled up a random Windows DLL to look at... LabVIEW has the option to allow the arguments to be passed by "Value" or by "Pointer to Value", except for the first argument originally labeled "return type", which must have a standard default since the property does not appear.
06-21-2005 10:27 AM
06-21-2005 10:42 AM - edited 06-21-2005 10:42 AM
@lou 83 wrote:
Thank you for your advice. It has cleared up a few things for me. I have tried the "Pointer to Value" option in the call library node, but I still get 0 for my object pointer. A small portion of the dll wrapper that I wrote to access the pointer is again repeated below:
_declspec(dllexport) void function (vtkRenderWindow *renWin)
{
renWin = vtkRenderWindow::New(); //creates new instance of type vtkRenderWindow
}
Originally, the object creation line looked like this:
vtkRenderWindow *renWin = vtkRenderWindow::New();
I moved the declaration into the function prototype so that I could access it from LabVIEW.
I know that renWin is being created properly because the code works. However, I still get 0 for the object pointer and I have tried passing by reference and by value.
Should I be casting it to a uInt32 or something like that?
Is there a C++ command that will return the value of a pointer?
Thank you again,
Louis
Message Edited by rolfk on 06-21-2005 10:49 AM
06-22-2005 04:08 PM
06-23-2005 03:14 AM
@lou 83 wrote:
Thanks for your advice. It worked and it makes sense to me. You were right that the other functions take in a vtkRenderWindow *renWin parameter, however, I'm having trouble with the object methods. Normally I would write something like:
renWin->DoSomething();
But now it doesn't work, and I've tried
*renWin->DoSomething();
and
**renWin->DoSomething();
I keep getting an error C2227: left of '->DoSomething' must point to class/struct/union
Is there anything I can do about this?
Thanks again,
Louis
07-13-2006 07:26 AM
08-09-2006 10:10 AM