Reputation: 3
I am currently using PyCUDD, which is a SWIG-generated Python wrapper for the C package CUDD. I'm currently trying to get CUDD to print some debug information from inside the C code, but any printfs inside the C code don't seem to be producing any output - putting them in the .i files for SWIG produces output, putting them in the C code does not. I'm not sure if this is some property of SWIG specifically or of compiling the C code to a shared object library.
(Particularly frustrating is that I know that I have had this problem and gotten it working before, but I can't seem to find anything searching for the problem now, and I apparently forgot to leave notes on that one thing.)
Upvotes: 0
Views: 1495
Reputation: 3
I still forget what my problem was before. However, I have found that what was causing my problem here was a linker issue - the linker was looking at an old version of the library, which did not have my changes.
Upvotes: 0
Reputation: 151
I think problem is that Launched program closes (or redirects original stdout handler/descriptor to somewhere) stdout, so Library cannot gets Handler/descriptor. So I tried to recover devices and reopen.
In linux, console device is located at /dev/stdout (it is symbolic link to specific devices or file located in fd 1 at launched time), so reopen this file and recover file descriptor.
int fd = open("/dev/stdout", O_RDONLY);
if(fd != -1)
dup2(fd,1);
In Windows, AllocConsole tries to create new Console if current process does not have console. This is for the case when PyCUDD(Or any program) uses custom console. And freopen makes writable to our allocated console, so printf will work for new console.
AllocConsole();
freopen("CONOUT$", "w", stdout);
Upvotes: 0