Sign in to follow this  
formalproof

Where do STL I/O functions map to in Windows?

Recommended Posts

As far as I know, each compiler maps C++/STL functions to it's systems own functions. So when using Visual C++, STL I/O capabilities are probably mapped to some Win32 API functions. Does this mean that using STL I/O functions in a Windows program is slower than using the corresponding Win32 functions directly? I also recall reading that in a windowed system std::cout should print text to a window. So I tried making a C++/CLI program to test it, but I couldn't get it to work, which probably isn't surprising, but I'd still like to know why? Wasn't cout meant to work anywhere in all kinds of systems? So why doesn't it just print text to the programs default form window? Is there some way to find out exactly on what system functions the STL functions map to on a windows system?

Share this post


Link to post
Share on other sites
Quote:
Original post by formalproof
As far as I know, each compiler maps C++/STL functions to it's systems own functions. So when using Visual C++, STL I/O capabilities are probably mapped to some Win32 API functions. Does this mean that using STL I/O functions in a Windows program is slower than using the corresponding Win32 functions directly?
Yes and no. Yes, but only very very slightly, and they provide buffering and other things that will more than make up for it.

Quote:
Original post by formalproof
I also recall reading that in a windowed system std::cout should print text to a window. So I tried making a C++/CLI program to test it, but I couldn't get it to work, which probably isn't surprising, but I'd still like to know why? Wasn't cout meant to work anywhere in all kinds of systems? So why doesn't it just print text to the programs default form window?
You don't want to use CLI, you just want a native Console application. I assume that's the problem (I've never used CLI before).

Quote:
Original post by formalproof
Is there some way to find out exactly on what system functions the STL functions map to on a windows system?
You can trace into the functions (With F11 from the debugger), although you'll need the CRT source code. I'm not sure if you can download it; I know it comes with VS2005 Professional.

I belive that the iostreams code eventually calls WriteFileEx or WriteConsoleOutput to do the low level output.

Share this post


Link to post
Share on other sites
Quote:
Original post by formalproof
I also recall reading that in a windowed system std::cout should print text to a window. So I tried making a C++/CLI program to test it, but I couldn't get it to work, which probably isn't surprising, but I'd still like to know why? Wasn't cout meant to work anywhere in all kinds of systems? So why doesn't it just print text to the programs default form window?


Quote:
You don't want to use CLI, you just want a native Console application. I assume that's the problem (I've never used CLI before).


Well, I just wanted to see if it works in a non-console WinForms application.

What I originally wanted to do was port a C++/STL console program to a windowed C++/CLI program with minimal modifications, so I thought maybe there would be a way to make std::cout print directly to a form window, but there doesn't seem to be one.

Quote:
You can trace into the functions (With F11 from the debugger), although you'll need the CRT source code. I'm not sure if you can download it; I know it comes with VS2005 Professional.

I belive that the iostreams code eventually calls WriteFileEx or WriteConsoleOutput to do the low level output.


I'll check that out. Thanks for the answers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this