[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C Interface Issue
Re: C Interface Issue
Sun, 16 Dec 2012 08:39:22 -0800 (PST)
If "extern" in C works when linked by plgc, I don't even need to pass the
pointer. I'll try it.
Daniel Diaz-3 wrote:
> Hi John,
> The simplest way to pass pointers across Prolog and C is to store them
> into a global array t at index i and pass i as a Prolog integer.
> Obviously you can also directly store the structure in the array (this
> could avoid a malloc/free for the struct, but requires more memory if the
> array is large). The Prolog code receives an integer (which it does not
> use) and passes it back to another C code which recover i and uses t[i].
> Did I miss something ?
> Le 15 déc. 2012 à 22:05, mcculloch <address@hidden> a écrit :
>> I've looked into various prologs and have decided Gnu Prolog is the
>> to interface to other systems via C routines. However, there doesn't
>> to be a good way to pass C struct pointers back to prolog for use by
>> foreign predicate calls implemented in C. I think now maybe that might
>> be a good idea anyway.
>> The C interface I want to use creates a structure to represent a
>> to a foreign system, and then requires this structure to subsequently
>> the system. (For those who are curious, the system is mongoDB).
>> One option is to create this structure, use it and destroy it every time
>> predicate is called that uses that system. Obviously, this is very
>> inefficient. The other option is to provide a predicate that returns the
>> connection structure back to prolog to provide to other predicates, but
>> is exactly what I can't figure out how to do in gprolog.
>> Any ideas would be greatly appreciated, and of course, any code that I
>> develop to completion will be shared.
>> Sorry this ended up in Bugs where it doesn't belong. I'll try and figure
>> out how to move it.
>> View this message in context:
>> Sent from the Gnu - Prolog - Bugs mailing list archive at Nabble.com.
>> Bug-prolog mailing list
>> Ce message a ete verifie par MailScanner
>> pour des virus ou des polluriels et rien de
>> suspect n'a ete trouve.
> Ce message a ete verifie par MailScanner
> pour des virus ou des polluriels et rien de
> suspect n'a ete trouve.
> Bug-prolog mailing list
View this message in context:
Sent from the Gnu - Prolog - Bugs mailing list archive at Nabble.com.