I am reading Charles Petzold's Programming windows. 5th Edition. And there is a statement to Windows.h file.
It said.
There is a WINNT.H file included in Windows.h file.
And the WINNT.H file used to define Unicode support.
But I can't find it in Visual Studio 8.0 Windows.h file.
And the file (WINNT.H) is not existing in Windows.h in VS 8.0, How can the Unicode support function be realized?
If you have the Visual C++ component of Visual Studio installed (i.e. if you can compile .cpp files), then you have WINNT.H. As well as Windows.h (which implicitly #include's WINNT.H for all Win32 targets).
It should be under "\includes" in your MSVS install directory.
In earlier versions of MSVS, 8-bit ASCII was the default, and you had to explictly "#define _UNICODE" (e.g. as a compile option). Newer versions (I believe starting in MSVS2005, but certainly now in MSVS2008 and MSVS2010), 16-bit Unicode is the default.
Related
I am using a library which is compiled in visual studio using the multibyte character set option.
The library is being used in a MFC project which is using the Unicode character set.
At compile and link time I am not running into any issues.
Are there any runtime "gotchas" that I shoushould aware of?
I'm taking a 32-bit source library and compiling on a 64-bit platform and getting alignment issues (not only 32-bit vs 64-bit but also character set as well).
I want to place all the 64 bit configurations into a "Win64" folder and the 32-bit configurations into a "Win32" directory.
I'm looking into some guidance for modifying the project file so that the target library and dll filenames will be in terms of the configuration.
Examples:
Win64/testrunner_x64d.lib -- Library, debug, 64-bit platform, ASCII
character set.
Win64/testrunner_x64ud.lib -- Library, debug, 64-bit platform,
Unicode character set.
Win32/testrunner_x32d.lib -- Library, debug, 32-bit platform, ASCII
character set.
Win32/testrunner_x32ud.lib -- Library, debug, 32-bit platform,
Unicode character set.
I'm new to using configurations in Visual Studio 2010 and also porting an existing project.
For the character setting, go to "Configuration Properties"->"General"->"Project Defaults"->"Character Set", chose the one as you wish.
For the lib's name for different configuration, you can set it via "Linker"->"General"->"Output File"
Can i replace mfcs90.lib with mfcs100.lib while converting VS2008 project to VS2010 project
Yes you can and should. Looking around I have found some documentation that may help and explain a bit more about what you need to do.
These MFC link libraries are lightly documented by Microsoft's TN033 Tech Note: http://msdn.microsoft.com/en-us/library/hw85e4bb.aspx
A quick summary about the mfcsxxx.lib files is: The MFCSxx[U][D].LIB libraries are used in conjunction with the MFC shared DLLs. These libraries contain code that must be statically linked to the application or DLL.
* The "U" designates that the library is built for Unicode.
* The "D" designates that the library is built for Debug.
* If the number in the library is 90, then it's compiled with and for Visual Studio 2008 (VC++ 9.0)
* If the number in the library is 100, then it's compiled with and for Visual Studio 2010 (VC++ 10.0)
Note that while the mfcsxxx.lib files have code that is statically linked to the output binary, they are used in conjunction with the DLL versions of MFC - when statically linking MFC, the [nu]afxcw[d].lib libraries are used (where "n" or "u" determines whether or not the library is Unicode, and "d" is used in Debug builds).
I'm trying to compile some code from a Windows API. It says that certain .lib and .h files must be included in the version of the Windows 7 SDK I am using. Visual Studio shows the .h files, but gives linker errors (L2019) when I try to build the project.
How can I check what version of the Win7 SDK I have, and how can I see if it includes the necessary .lib files?
Did you actually tell the linker that it should link the corresponding .lib file? The project templates only link the most popular .lib files, kernel32.lib, user32.lib etc. If you use an "unusual" API function then you must also tell the linker to link the import library.
Project + Properties, Linker, Input, Additional Dependencies. If you don't know what .lib is needed then look in the SDK documentation for the API function. The .lib file is listed at the bottom of the article.
Another thing you can do is use a #pragma in your source code to tell the linker to link with a .lib. For example:
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib") // NOTE: need to link this .lib to get shell functions
Possible solution: Go to "C:\Program Files\Microsoft SDKs\Windows" and see if there is a version installed (or if that path exists at all).
Is there a quick way to determine whether a Visual Studio C++ project is written in plain C++ or Visual C++?
If any files include the lines #pragma once or #include "stdafx.h", it's very likely Visual C++.
(Are there any other compilers that implement #pragma once?)
No -- Visual C++ will compile most plain C++ without any problems. If you want to check for use of Windows-specific "stuff", checking for inclusion (directly or indirectly) of <windows.h> would probably be a reasonable start.
If is Visual C++ it usually has a project.sln or project.vcproj file in the project directory.