passing FILE pointers to a non-MSVC++ compiled extension type???
sholden at holdenweb.com
Fri Aug 10 02:25:13 CEST 2001
"doug" <doug_bartholomew99 at yahoo.com> wrote in message
news:e71960c5.0108091604.3b2f589f at posting.google.com...
> is there someway i can write an extenstion type's print method so that
> instead of fprintf-ing to the FILE* directly, i call back to some
> python c api function with the c string of what i want to print???
> i have written an extension type which defines its own print method.
> when it is compiled/linked under MSVC++ 6.0, the resulting .pyd works
> correctly. however, when compiled/lined with borland's command line
> compiler/linker, the print method causes the python session to crash.
> in particular, the offending line within the print method is:
> fprintf(fp, "%s", (Self->Data).ReturnCString()); // fp causes crash
> i have read that other people have had the same problem, bc FILE
> pointers (which the variable fp is) cannot be passed between between
> MSVC++ compiled code and Borland-compiled code.
> a not-so-elegant workaround is to replace the above offending line in
> the print method with:
> std::cout << (Self->Data).ReturnCString(); // notice no fp is used
> but this only works when python is run in a console window and doesnt
> work when the interpretter is embedded in a windows app (like
> PythonWin) where python redirects its own output.
> i absolutely have to use the borland compiler bc for the rest of my
> project, i use fairly intricate (though perfectly standard) c++ code
> which MSVC++ cant compile but borland will. i have read in a long ago
> post that this is because borland and msvc++ use different RTLs. is
> there a workaround within the python c api for this??? is there
> someway i can rewrite my print method so that instead of fprintf-ing
> to the FILE* directly, i call back to some python c api function with
> the c string of what i want to print to the console???
See the thread including
for a fairly thorough airing of this topic.
now-activstate's-mail-archives-appear-in-google-ly y'rs - steve
More information about the Python-list