From jan@swi.psy.uva.nl Thu Sep 27 10:05:24 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f8R85Nv28759;
	Thu, 27 Sep 2001 10:05:23 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f8R85NG26160;
	Thu, 27 Sep 2001 10:05:23 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Armando Stellato <starred@tiscalinet.it>,
   SWI Mailing List <prolog@swi.psy.uva.nl>
Subject: Re: Problems with foreign libraries using dlls
Date: Thu, 27 Sep 2001 09:59:32 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <3B6AB42F.12B136FC@tiscalinet.it> <3B6AB45A.9A555A76@tiscalinet.it> <3B6AC16B.772A5BAE@tiscalinet.it>
In-Reply-To: <3B6AC16B.772A5BAE@tiscalinet.it>
MIME-Version: 1.0
Message-Id: <01092710052304.25592@gollem>
Content-Transfer-Encoding: 8bit

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

