Subject: Re: Problems with foreign libraries using dlls

From: Jan Wielemaker <[email-masked]>
Date: Thu, 27 Sep 2001 09:59:32 +0200

On Fri, 03 Aug 2001, Armando Stellato wrote:
>Well, the problem with the CPP version was that the SWI-Prolog win shell is no
>standard output, infact the writings appear on a dos shell.
>Anyway I've still problems with the pure C version.
>I'm sorry if I'm posting so many messages but I've been on this problem for 2
>days before posting anything, just to see if i could solve the problem by me,
>and today things are getting better, so i prefer to post messages explaining
>what i've solved and what i've yet to do to save time to other people who were
>going to reply to my msgs.
>Thanx again
>Armando
>
>> if I write hello/1 (example: hello(world)): it says me only yes!!! it
>> ignores the cout in the c declaration:
>> cout << "name = " << A1.name() << ", arity = " << A1.arity() << endl;
>> return TRUE;
>>
>> Well it's three days that i'm fighting against him...help!!

For proper integration you've got to use the SWI-Prolog stream functions
for I/O.  These are defined in SWI-Stream.h, but only provide C stdio
style of input and output.  For example:

#include <SWI-Stream.h>
#include <SWI-Prolog.h>

  ...
  Sprintf("Hello World\n");

You find the prototypes of these functions in SWI-Stream.h.  As a rule
of thumb, this is S, followed by the traditional C stdio name.

Using SWI-Prolog streams ensures proper integration with the Prolog
I/O buffers, that your output is properly redirected to the plwin
window and visible in captured output using protocol/1.

	Regards --- Jan