[cffi-devel] Re: CFFI + Slime + std::cout
The following message is a courtesy copy of an article that has been posted to comp.lang.lisp as well. Sohail Somani <sohail@taggedtype.net> writes:
How can I get Slime to relay the output (through std::cout) of a C++ function called through CFFI through to the REPL?
This is really a CFFI question, and you may wish to send further followups to the CFFI list instead. Create a C++ shared library with a few elements, then load and initialize it using CFFI: 1. A subclass of std::ostream that holds a void(*)(const char*) as an instance variable, forwarding all output received to that function. 2. A function like extern "C" void init_mylispcout (void (*writer) (const char*)); that replaces std::cout with an instance of #1. I forget whether C++ allows you to change std::cout. 3. A CFFI callback in Lisp to be passed to #2, that writes the output on some Lisp stream. 4. A CFFI defcfun on #2. -- But you know how reluctant paranormal phenomena are to reveal themselves when skeptics are present. --Robert Sheaffer, SkI 9/2003
participants (1)
-
Stephen Compall