• Advertisement
Sign in to follow this  

Question about C++ Windows libraries

This topic is 4222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm starting Windows programming, and I'm noticing there's a library for everything. I mean, they replace "normal" c++ libraries. So is there a reason why I should use the Windows version of library when I already know how to use a standard c++ equivalent? The specific case I am thinking of- I know how to use <fstream> but Windows has it's own library for file access which looks harder to use. Should I bother learning the Windows version, or just stick to fstream?

Share this post


Link to post
Share on other sites
Advertisement
My experience was to learn it and then not use it. I don't like the windows FILE idioms, but you should know them in case you ever need to work with them. If you're ever on a team that uses them: When in Rome, do as the Romans do.

EDIT:
The other posters below reminded me: you should also check out boost's take on filesystem tasks. The standard library classes are a little simplistic, and boost complements them very well.

Share this post


Link to post
Share on other sites
Quote:
Original post by polaris2013
I'm starting Windows programming, and I'm noticing there's a library for everything. I mean, they replace "normal" c++ libraries. So is there a reason why I should use the Windows version of library when I already know how to use a standard c++ equivalent? The specific case I am thinking of- I know how to use <fstream> but Windows has it's own library for file access which looks harder to use. Should I bother learning the Windows version, or just stick to fstream?


The c++ standard libraries are still user code, ie they cannot do many things the os must do (allocate memory, talk to hard disks). You will find that the c++ standard libraries are built on top of os specific code for these things. So in a sense you are already using win32 file stuff isf you use fstream.

The only reason you should use os-specific stuff is that it can often be more flexible and do more, for example c++ has no standard library compreheding directories, so you could use win32 for that. Or file attributes or access rights.

IMO use c++ ones where you can, as you said it can be harder i prefer the c++ i/o myself ).

Share this post


Link to post
Share on other sites
If you need some advanced features that fstream doesn't offer to you - use windows version.

Note: std::fstream (C++) and FILE* (C) both use the windows version on windows OS, some other api on other operating systems (so if you need to compile your project on other platforms - you won't have to change anything).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
And I wouldn't say the Windows File Management API replaces the "normal" C++ library as you say it; it's more like the "normal" C++ library replaces the WFM API. CreateFile was there for at least 3 or 4 years before any compiler even had an STL implementation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement