[erlang-questions] C++ port having trouble printing to cout

Michael Truog mjtruog@REDACTED
Mon Aug 17 23:08:56 CEST 2009


Erlang ports normally use stdin/stdout for communication.  To change it
use erlang:open_port/2 with option nouse_stdio so that erlang does not
communicate on stdin/stdout.  Remember std::cerr is still available
either way, and for some reason the linux/unix erlang shell prefers
"\r\n" instead of std::endl ("\n") when outputting to stderr.

Erickson, John wrote:
> Hi, I have written a C++ port for some Erlang code and although I am able to get data in and out of the port without any problems, trying to do output in the C++ code with cout is unreliable.  Usually if something is printed in Erlang after the call to the port returns, it will be printed instead of the last couple hundred lines of output from C++.  I have tried putting cout.flush() in my code but it does not help.  Single stepping through the code in gdb will print all output, but anytime I run at full speed I lose output.
>
> John
>
>   



More information about the erlang-questions mailing list