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

Started by
1 comment, last by formalproof 15 years, 9 months ago
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?
Advertisement
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.
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!

This topic is closed to new replies.

Advertisement