Hi,
In the distributed examples, the "MyDll" example exports a function of type (string) -> (string), but that is consumed by another VIP program. How do I call this from a C/C++ program?
Thanks,
Rangarajan
-
- VIP Member
- Posts: 1466
- Joined: 28 Feb 2000 0:01
Re: Need example of C function calling VIP DLL
You will use a vip-dll in the same way as you use other dll's.
Exactly how that is depends on you C++ system, and is really a question for some C++ forum.
But it involves declaring C++ pendants to the vip predicates and linking with the lib (or loading the DLL dynamically).
The predicate from the example:
can (I guess) have a C++ declaration like this:
extern "C" avoids name mangling of the link name.
Notice however that Visual Prolog strings (and other memory) are garbage collected and since the vip DLL cannot see which memory the C++ part references; memory will be garbage collected when it is no longer live from the vip part, even though the C++ part still references it (have it live).
Exactly how that is depends on you C++ system, and is really a question for some C++ forum.
But it involves declaring C++ pendants to the vip predicates and linking with the lib (or loading the DLL dynamically).
The predicate from the example:
Code: Select all
predicates
touch : (string String) -> string Touched language stdcall as "touch".
Code: Select all
extern "C" wchar_t* __stdcall touch(wchar_t* String);
Notice however that Visual Prolog strings (and other memory) are garbage collected and since the vip DLL cannot see which memory the C++ part references; memory will be garbage collected when it is no longer live from the vip part, even though the C++ part still references it (have it live).
Regards Thomas Linder Puls
PDC
PDC
-
- Posts: 18
- Joined: 1 Jun 2007 14:51
Re: Need example of C function calling VIP DLL
Thank you!
Regards,
Rangarajan
Regards,
Rangarajan