A few days ago I submitted patch with small fixes for Boost.Build to support Visual Studio 11 toolset. The patch has been accepted and committed to the current trunk in Boost repo. Thanks to Volodya for reviewing the patch.
Tag Archives: visual studio
Visual Studio 11 support for Boost.Build
I have just submitted patch with update for Boost.Build machinery to properly detect Visual Studio 11 (currently available as Developer Preview).
I have very little experience with Boost.Build v2 internals, so the patch may need further improvements. It works in my environment on Windows 7 (64-bit) with Visual Studio 2010 Express Edition installed alongside the Visual Studio 11 Developer Preview.
If you want to use Visual Studio 11 as Boost.Build toolset, just put the following entry in your user-config.jam file:
using msvc : 11.0 ;
To verify if the toolset is recognised correctly, use b2 debugging options:
b2 --debug-configuration --debug-building --debug-generator buffer.cpp notice: found boost-build.jam at D:/dev/boost/_svn/trunk/boost-build.jam notice: loading Boost.Build from D:/dev/boost/_svn/trunk/tools/build/v2 notice: Searching C:\Windows C:\Users\mloskot C:\Users\mloskot D:\dev\boost\_svn\trunk\tools/build/v2 D:/dev/boost/_svn/trunk/tools/build/v2/kernel D:/dev/ boost/_svn/trunk/tools/build/v2/util D:/dev/boost/_svn/trunk/tools/build/v2/build D:/dev/boost/_svn/trunk/tools/build/v2/tools D:/dev/boost/_svn/trunk/tool s/build/v2/contrib D:/dev/boost/_svn/trunk/tools/build/v2/. for site-config configuration file site-config.jam . notice: Loading site-config configuration file site-config.jam from D:/dev/boost/_svn/trunk/tools/build/v2/site-config.jam . notice: Searching C:\Users\mloskot C:\Users\mloskot D:\dev\boost\_svn\trunk\tools/build/v2 D:/dev/boost/_svn/trunk/tools/build/v2/kernel D:/dev/boost/_svn/ trunk/tools/build/v2/util D:/dev/boost/_svn/trunk/tools/build/v2/build D:/dev/boost/_svn/trunk/tools/build/v2/tools D:/dev/boost/_svn/trunk/tools/build/v2/ contrib D:/dev/boost/_svn/trunk/tools/build/v2/. for user-config configuration file user-config.jam . notice: Loading user-config configuration file user-config.jam from C:/Users/mloskot/user-config.jam . notice: [msvc-cfg] msvc-11.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe' notice: [msvc-cfg] msvc-10.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe' notice: [msvc-cfg] msvc-10.0express detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe' notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe' for msvc, condition <toolset>msvc-11.0 notice: [msvc-cfg] condition: '<toolset>msvc-11.0/<architecture>/<address-model>', setup: 'call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcv arsall.bat" x86 >nul ...
and look for the following message reported:
notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe' for msvc, condition <toolset>msvc-11.0
Visual Studio 11 visualizers for Boost.Geometry
Some time ago Barend Gehrels blogged about Visual Studio 2010 debugger visualizers for Boost.Geometry. Barend’s templates added to autoexp.dat file are of great help while working with the Boost.Geometry library in Visual Studio.
Recently, I’ve started using Visual Studio 11 Developer Preview and discovered the new style debugger visualizers this new edition introduces. I decided to port Barend’s work to the new XML-based format in .natvis files.
All my visualizers, not only for Boost.Geometry but also for other libraries, are available in visualstudio11 Git repository on my GitHub. The .natvis files are not overly complicated and the installation is dead easy, see README file attached.
Comments, suggestions and fixes are welcome.
Quick fix for CMake broken Visual Studio 11 .sln
Current CMake 2.8.6 generates broken .sln files for Visual Studio 11 Developer Preview. The bug has been fixed already in CMake upstream.
Meanwhile, I have become annoyed by manually fixing the solution files. Here is quick .bat script I call from my cmake-{project}.bat proxy scripts I maintain for every project configured with CMake. So the fix is applied automatically every time I run CMake:
@echo off REM Fix broken Visual Studio 11 .sln generated by CMake 2.8.6 (or earlier) set SED="C:\Program Files (x86)\GnuWin32\bin\sed.exe" set SLN=%1 copy %SLN% %SLN%.copy %SED% "s/Studio 2011/Studio 11/g" %SLN%.copy > %SLN% del /Q %SLN%.copy
Modular visualizers in Visual Studio 11
Previously, I talked about the new debugger visualizers in Visual Studio 11 (Developer Preview) based on XML. By the way, I haven’t any luck trying to figure out where does the file type .NATVIS come from.
In previous versions of the Visual Studio, all templates of debugger visualizers have to be saved in single file: %VSINSTALLDIR%\Common7\Packages\Debugger\autoexp.dat. In case one wants to extend or improve the templates definition, maintaining everything in one system-wide file is neither practical nor safe.
The visualizers in Visual Studio 11 seem to solve the maintenance hassle by allowing more modular approach. First nice feature is that custom templates can be defined without touching any of the installed Visual Studio files and can be put in %USERPROFILE%\Documents\Visual Studio 11\Visualizers. Second nice feature I’ve just discovered is that definitions of visualizers can be split into several separate .natvis files. It is especially useful if one wants to maintain visualizers grouped according to libraries (e.g. Loki, Boost, POCO).
Basically, %USERPROFILE%\Documents\Visual Studio 11\Visualizers works like a package of custom visualizers now:
Having the visualizers diagnostics enabled, whole process of parsing and loading .natvis files will be traced in Visual Studio 11 output window:
No more copying and pasting debugger visualizers for Boost and others into big muddy autoexp.dat.
BTW, who knows where does NATVIS come from, hmm? :-)
Setting EnableNatvisDiagnostics in Visual Studio 11
Previously, I posted about the new XML-style debugger visualizers I discovered in Visual Studio 11. I mentioned that one of reasons the feature has been redesigned is to enable debugging of the visualizers templates defined in default or user-defined .natvis files. So, it looks there is something more to discover: how to actually make use of the diagnostics capability.
Unfortunately, it seems the new debugger visualizers have not been documented anywhere. At the time of writing this blog, Google reports one link about defaultvis.natvis, it is the brief post on Visual C++ forum.
Luckily, there is a short manual included as comment in header of the %ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Packages\Debugger\Visualizers\defaultvis.natvis file. It says:
1) give better diagnostic reporting.
a) Set the name-value entry under the Debugger registry key: EnableNatvisDiagnostics which is a REG_DWORD to a value of 1 this will output each expression string that is evaluated under the native visualizer into the output window and is good for debugging type definition typos in .natvis files.
The first thing is to figure out where to set the EnableNatvisDiagnostics flag. The Visual Studio 11 installer does not put it into the registry. Also, there are several Debugger keys. However, a few experiments proved the flag should be set under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\Debugger:
Once it is set, every time Visual Studio 11 debugger is launched and use of visualized types is determined, the .natvis files are parsed and evaluated templates validated. The process is reported in the Output window:
If anything goes wrong, a type definition template is incorrect and its evaluation fails, it is also reported in the Output window:
It will be a very useful feature especially when defining visualizers of complex types. Previous versions of Visual Studio used old format of templates defined in autoexp.dat file which stated its own DSL based on regular expressions, so the syntax was complex and fragile, and as Andy Pennel has confessed, not documented. (Here kudos to Avery Lee who did great job reverse-engineering the autoexp.dat syntax.)
At least, this time folks get the XML Schema for the Visual Studio debugger visualizers.
Debugger visualizers in Visual Sudio 11 Developer Preview
Visual Studio 11 Developer Preview introduces new style debugger visualizers. The autoexp.dat definition of templates in previous versions of the Visual Studio debugger is being replaced with new style definitions based on XML and stored in defaultvis.natvis file.
Microsoft explains the motivation behind redesigning the native type visualization mechanism is to give better diagnostic reporting (visualizer expressions can be now evaluated and displayed in the output window to help debugging .natvis file), provide XSD schema defining type definition, support of multiple files for type definition: system-wide in %ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Packages\Debugger\Visualizers\defaultvis.natvis and user-defined in %USERPROFILE%\My Documents\Visual Studio Dev11\Visualizers\xxx.natvis.
It sounds really good and has a great usability potential for programmers who uses C++ generative programming capabilities, defines complex C++ types, heavily uses C++ Standard Library and Boost C++ Libraries.
Here is example of new style visualizer defined in XML copied from the defaultvis.natvis:
<!--std::unique_ptr from <memory>-->
<Type Name="std::unique_ptr<*>">
<DisplayString Condition="_Myptr == 0">empty</DisplayString>
<DisplayString>unique_ptr {*_Myptr}</DisplayString>
<Expand>
<Item Name="[ptr]" Condition="_Myptr != 0">_Myptr</Item>
</Expand>
</Type>
For most types from C++ Standard Library and Windows SDK, the new visualizers work very well. However, the currently available Visual Studio 11 Developer Preview (Version 11.0.40825.2 PREREL) is shipped with incorrect definitions in the defaultvis.natvis. The C++TR1 definitions introduced in Visual Studio 2008 are only forwarded (aliased) from std:tr1:: to std:: in Visual Studio 2010. In Visual Studio 11, they have completely moved from std::tr1:: to std:: to align with C++11 standard. But, the new visualizers in defaultvis.natvis define templates are still referring to the C++11 types in std::tr1:: namespace.
This prevents the correct visualization for types like std::shared_ptr:
There is an easy workaround possible:
- Make private copy of
defaultvis.natvisin%USERPROFILE%\My Documents\Visual Studio Dev11\Visualizers\xxx.natviswhere xxx is your preferred name. - Open
xxx.natvisin a text editor. - Find
std::tr1::and replace withstd::. - Save the changes and relaunch the Visual Studio 11.
- You should see objects of the C++11 types correctly visualized.
I have reported this issue to Microsoft Connect in Incorrect Type Name references in defaultvis.natvis visualizers for standard library ticket.







