471,326 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,326 software developers and data experts.

stdout and embedding into Windows apps

Hi,

I'm extending a windows application (C++) by embedding Python calls. It
seems to be a known problem that windows applications detach immediately
from the calling console, so that all output to stdout (from both C++
and Python) doesn't get shown anywhere.

A workaround seems to be the allocation of a windows console and
redirecting stdout to it:

AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);

Still, this console only shows the output of my C++ application, not the
output of the embedded python calls.

The following code
Py_Initialize();
std::cout << "start printing..." << std::endl;
PyRun_SimpleString("print('PRINT')\n");
std::cout << "done printing." << std::endl;

only prints

start printing...
done printing.

Does anybody know how to fix this issue? Basically I want to get an
ipython console running in the background of my Windows app, so that I
can process its data.
Cheers,
Thomas

Sep 19 '07 #1
0 1070

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Alicia Haumann | last post: by
reply views Thread by lickspittle | last post: by
reply views Thread by bwaha | last post: by
8 posts views Thread by John Forkosh | last post: by
7 posts views Thread by Mr. Roboto | last post: by
2 posts views Thread by Greg Ercolano | last post: by
reply views Thread by Tom Gaudasinski | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.