Re: print, writeln etc. fail when calling from C program on Win32

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 04/01/2014 01:42 AM, Kaitain Jones wrote:
> I'm getting caught out at the moment by having any PL clauses that make any
> output-related side-effect calls such as print or writeln fail when calling
> them from my C wrapper on Win32, meaning that the predicate itself fails
> even though I have no interest in the print output in this context (but I
> want to see the output when submitting queries from the SWI repl). I was
> trying to work out if there was a simple way of allowing the print/write
> calls to succeed (in terms of returning true) even if no output was ever
> delivered anywhere. I had a look at the documentation on the SWI knowledge
> base but I found that section a bit sketchy and couldn't glean meaningful
> answers from it.

I think they raise errors, no?  Nothing specifically is arranged, so they
translate whatever write() returns when writing to stdout, etc.

You can do something similar as done in src/pl-ntconsole.c, which rebinds
the I/O streams to use the Windows console functions and achieve Unicode
I/O as well as color output.  You can change the functions doing the I/O
to use the Windows debug output functions or simply discard the output
or whatever you like.

As a final remark, you might have a look at library(debug), which provides
debug/3 for writing debug messages.  It allows selectively enabling or
disabling debug messages, optionally tagging them with the calling thread
and/or a time stamp, redirecting (some) debug channals to a file, etc.
Finally, if your program is compiled in optimized mode, the debug statements
are simply replaced by 'true' and subsequently discarded by the compiler.

	Cheers --- Jan


> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.