aabuezo wrote: |
---|
I mean, all that stuff. You don't need those Unicode libraries and macros like _tmain or _tWinMain or TEXT(), or whatever specific to MS, to write standard ANSI C++ programs (named as native C++ by Horton to make a difference with these MS specifics and C++/CLI). |
This is all correct. Visual Studio is perfectly capable of writing programs that only use standard libs and do not use anything MS specific.
I think we agree, I'm just getting a little confused by your terminology.
If you access to a windows api like say, networking, from a console application, you just can stick to char or wchar_t and access the A or W ended versions of the winapi functions, writing standard C++ without using those _tchar TEXT() macros, etc. Am I right? |
Yes. In fact I recommend it, since chars/wchar_ts are much, much easier to work with and are less error prone. I avoid TCHARs like the plague.
Although... another terminology quirk here. The 'TEXT' macro is not a
C++ standard but it is certainly a
WinAPI standard. And if you're already using WinAPI for its networking functions... then you're already going outside the C++ standard, so it doesn't hurt to use additional things from WinAPI (like the TEXT macro).
It's not like VS is the only compiler to support the TEXT macro -- all compilers support it. It's not even a compiler feature, it's a part of a library.
NT3 wrote: |
---|
Sorry I'm a bit late in, but I'll just clarify - I meant the book might be doing that, I never meant to suggest that they should be used. |
Fair enough. I just see this problem come up on these forums
all the time. It's a very simple problem, but tutorials/books either seem to avoid it, or don't seem to understand it and teach the wrong thing, so I get a little frustrated when I see it now.
then, what is the aim to keep using MessageBoxA. |
NT3 mentioned backwards compatibility. But it's also for convenience. If you have string data (like from a file or soething) that is not UTF16, and you know it only contains ASCII characters, it's easier to output it to an 'A' function than to manually widen it to UTF16 and output it with a 'W' function.
Calling the 'A' function has the same effect in that case, and Windows simply does the widening for you so you don't have to do it yourself.
Though there is the question of how long the 'A' functions will continue to be supported. I have heard from different people that they have been deprecated, although I have not seen anything on any official source which supports that, so it might just be a rumor.
Frankly, I think there is too much code out there using it for MS to ever deprecate the narrow API. It's more likely that they'll deprecate WinAPI entirely and replace it with some other API.