Linking to MSVCRT

Robin Allen r.a3 at ntlworld.com
Wed Jan 24 15:22:09 PST 2007


Lionello Lunesu Wrote:

> 
> "Robin Allen" <r.a3 at ntlworld.com> wrote in message 
> news:ep7tei$26c3$1 at digitaldaemon.com...
> > The Windows C runtime (MSVCRT.DLL) defines some functions, namely 
> > _open_osfhandle and _fdopen, that I need to use in my D program.
> >
> > However, D doesn't seem to link to the necessary libs by default; the 
> > linker says:
> >
> > Symbol Undefined __open_osfhandle at 8
> > Symbol Undefined __fdopen at 8
> >
> > Is there any way I can use these functions from D?
> 
> By the looks of it, those two seem to be simple wrappers for Win32's 
> CreateFile function. You could simply call CreateFile yourself. If you have 
> Visual Studio installed, you can peek at their source too, and just do 
> whatever those functions do in D.
> 
> L. 
> 
> 

They convert from Win32 HANDLEs to FILE*s and back; I was trying to use them to redirect stdout to a console window.

I'm just using WriteFile to write the strings instead of printf now, and that works just as well.



More information about the Digitalmars-d-learn mailing list