[erlang-questions] C++ port having trouble printing to cout
Erickson, John
john.erickson@REDACTED
Mon Aug 17 23:31:12 CEST 2009
Thanks for the suggestion, but that doesn't seem to solve my problem. I should have mentioned earlier, I am using spawn_driver, which I believe does not use any file descriptors. I also tried using cerr, but it does not seem to work any better.
-----Original Message-----
From: Michael Truog [mailto:mjtruog@REDACTED]
Sent: Monday, August 17, 2009 4:09 PM
To: Erickson, John
Cc: erlang-questions@REDACTED
Subject: Re: [erlang-questions] C++ port having trouble printing to cout
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