Sunday, November 27, 2011

Visual C++ 11 and Boost

Visual Studio / C++ 11 is currently at the Developer Preview level and as such doesn't have official support within libraries such as boost, even in the 1.48 release that came out in mid November 2011.
Despite this, the two will work together out of the box pretty much as is, with only a few warnings if you need to bootstrap in order to build the various libraries (for the non-header-only libraries, such as boost filesystem, etc).

Default Behaviour:

With a vanilla boost 1.48, after executing your VS vcvarsall.bat and running the boost bootstrap, you should get a successful build, with the following warnings:

bootstrapping issues:
cl : Command line warning D9035 : option 'GZ' has been deprecated and will be removed in a future release
cl : Command line warning D9036 : use 'RTC1' instead of 'GZ'
cl : Command line warning D9002 : ignoring unknown option '/MLd'

RTC1 is run time error checks.
GZ = Enable Stack Frame Run-Time Error Checking.

Why do these occur?  Turns out the boost batch files attempt to determine what your current compiler is, and with VC 11 it partially fails.

Cause of Warnings:

To begin with, the bootstrap calls into the build.bat file in
tools\build\v2\engine\

One of the first things this batch file tries to do is guess the toolset based on the environment variables set by visual studio.  You can find this in section :Guess_Toolset.
It starts with VC 10 and works its way down.  These all fail until eventually it finds that at least there's a VCINSTALLDIR, which sets it to VC7 mode (Visual C++ .NET 2002).

In and of itself, that's not as bad as it seems, because it's still calling cl.exe, which is the VC 11 compiler.  The issue is that later, down in the :Config_Toolset section it finds that we're using a VC 7 compiler and so passes the compiler a set of arguments suitable for VC 7, generating the warnings listed above.

Elimination of Warnings:

There are two steps we need to take to eliminate the warnings.

First we need to support VC11 in the :Guess_Toolset section.  It's just a minor copy and tweak from the VC 2010 detection code that we add before it, with VS100 changed to VS110 and vc10 updated to vc11:

call :Clear_Error
if NOT "_%VS110COMNTOOLS%_" == "__" (
    set "BOOST_JAM_TOOLSET=vc11"
    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
    goto :eof)

Second, we need support down in the :Config_Toolset in order to pass the correct parameters to the compiler.
The :Skip_VC10 section leads into the test for the borland compiler, but of course that needs to be changed to :Skip_VC11, as we add in a new section there for :Skip_VC10 which verifies we have VS 11 installed and sets the appropriate environment settings, else jumps to the :Skip_VC11 section (the borland test) to continue as before.

The new section is once more just a minor copy and tweak from the existing VC 2010 code, and is included below for completeness:

:Skip_VC10
if NOT "_%BOOST_JAM_TOOLSET%_" == "_vc11_" goto Skip_VC11
if NOT "_%VS110COMNTOOLS%_" == "__" (
    set "BOOST_JAM_TOOLSET_ROOT=%VS110COMNTOOLS%..\..\VC\"
    )
if "_%VCINSTALLDIR%_" == "__" call :Call_If_Exists "%BOOST_JAM_TOOLSET_ROOT%VCVARSALL.BAT" %BOOST_JAM_ARGS%
if NOT "_%BOOST_JAM_TOOLSET_ROOT%_" == "__" (
    if "_%VCINSTALLDIR%_" == "__" (
        set "PATH=%BOOST_JAM_TOOLSET_ROOT%bin;%PATH%"
        ) )
set "BOOST_JAM_CC=cl /nologo /RTC1 /Zi /MTd /Fobootstrap/ /Fdbootstrap/ -DNT -DYYDEBUG -wd4996 kernel32.lib advapi32.lib user32.lib"
set "BOOST_JAM_OPT_JAM=/Febootstrap\jam0"
set "BOOST_JAM_OPT_MKJAMBASE=/Febootstrap\mkjambase0"
set "BOOST_JAM_OPT_YYACC=/Febootstrap\yyacc0"
rem change it back because VC11 is not officially known.
set "BOOST_JAM_TOOLSET=msvc"
set "_known_=1"

After that you should be able to bootstrap warning-free.   
   
ps. It's amusing how often I see reference to the file "boostrap.bat"

Monday, November 14, 2011

Updating the shortshort list


I'm finding that my short (short) list of books to read has grown larger and more unwieldy than I'd like (about 90 books), and should probably be revised. So I thought I'd post it here for the following:
  • Comments on any couple of books that you think are most worthwhile to be on the shortlist.
  • Comments on any couple of books that you think are least worthwhile to be on the shortlist.

Obviously I'm looking for your opinion, and not whichever book has had the most impact on 19th century social trends, or whatever lists happen to measure...
And there's probably no point in suggesting other books to be promoted to the list since you won't know what I've read, but still...
Feel free to add qualifiers.

The Island of Doctor Moreau, H.G. Wells
The Book of Lost Things, John Connolly
Earth Abides, George R. Stewart
A Connecticut Yankee in King Arthur's Court, Mark Twain
The Dying Earth (Dying Earth Series #1), Jack Vance
Podkayne of Mars, Robert A. Heinlein
Anthem, Ayn Rand
Lord of the Flies, William Golding
The Sunset Warrior (The Sunset Warrior Cycle, #1), Eric Van Lustbader
The Snow Queen, Joan D. Vinge
Doctor Who and the Hand of Fear, Terrance Dicks
More Than Human, Theodore Sturgeon
Timescape, Gregory Benford
The Man in the High Castle, Philip K. Dick
Diaspora, Greg Egan
Double Vision, Tricia Sullivan
Spares, Michael Marshall Smith
Life of Pi, Yann Martel
Smashed: Growing Up a Drunk Girl, Koren Zailckas
Satan Burger, Carlton Mellick III
The Eyre Affair (Thursday Next, #1), Jasper Fforde
Summertide, Charles Sheffield
Tehanu: The Last Book of Earthsea, Ursula K. Le Guin
Divergence Tony Ballantyne
Light, M. John Harrison
Xenocide (Ender's Saga, #3), Orson Scott Card
Sex And Death in Television Town, Carlton Mellick III
Sausagey Santa, Carlton Mellick III
The Light of Other Days, Arthur C. Clarke
The Gospel of the Flying Spaghetti Monster, Bobby Henderson
Transmetropolitan Vol. 3 Revised: Year of the Bastard, Warren Ellis
Watchmen, Alan Moore
Elements of Programming, Alexander Stepanov
Mortal Engines (The Hungry City Chronicles, #1), Philip Reeve
The Collected Stories of Philip K. Dick 1: Beyond Lies the Wub, Philip K. Dick
Singularity Sky (Eschaton, #1), Charles Stross
The Shockwave Rider, John Brunner
The Burrowers Beneath, Brian Lumley
The Black Sun, Jack Williamson
Spin (Spin, #1), Robert Charles Wilson
Fools, Pat Cadigan
Fairyland, Paul J. McAuley
FlashForward, Robert J. Sawyer
Coraline, Neil Gaiman
A Fire Upon The Deep, Vernor Vinge
Hyperion (Hyperion, #1), Dan Simmons
Vernon God Little, DBC Pierre
Engines of Creation: The Coming Era of Nanotechnology, K. Eric Drexler
Star Maker, Olaf Stapledon
Revelation Space (Revelation Space, #1), Alastair Reynolds
The Speed of Dark, Elizabeth Moon
Schild's Ladder, Greg Egan
Stations of the Tide, Michael Swanwick
Where Late the Sweet Birds Sang, Kate Wilhelm
Ill Met in Lankhmar/The Fair in Emain Macha, Fritz Leiber
The Moon Is a Harsh Mistress, Robert A. Heinlein
The Golden Age (Golden Age, #1), John C. Wright
Tea From An Empty Cup (Artificial Reality Division #1), Pat Cadigan
Blood Music, Greg Bear
Mindstar Rising (Greg Mandel, #1), Peter F. Hamilton
The Ringworld Engineers, Larry Niven
Metal Fatigue, Sean Williams
Blood and Iron (Penrose 2), Tony Ballantyne
The Warrior's Apprentice (Vorkosigan Saga, #3), Lois McMaster Bujold
Falling Free, Lois McMaster Bujold
Iron Council (New Crobuzon, #3), China Miéville
Do Androids Dream of Electric Sheep?, Philip K. Dick
The Yiddish Policemen's Union, Michael Chabon
Tau Zero (Sf Masterworks), Poul Anderson
A Canticle for Leibowitz, Walter M. Miller Jr.
The Stars My Destination, Alfred Bester
The Road, Cormac McCarthy
The Lies of Locke Lamora (Gentleman Bastards, #1), Scott Lynch
China Mountain Zhang, Maureen F. McHugh
Last and First Men, Olaf Stapledon
Behold the Man, Michael Moorcock
Man Plus, Frederik Pohl
Forever Peace, Joe Haldeman
Oryx and Crake, Margaret Atwood
Bloodmind, Liz Williams
The City and The City, China Miéville
Stealing Light, Gary Gibson
Teeth and Tongue Landscape, Carlton Mellick III
Worldshaker, Richard Harland
Broken Angels (Takeshi Kovacs, #2), Richard K. Morgan
This is Not a Game, Walter Jon Williams
Halting State, Charles Stross
American Gods, Neil Gaiman
The White Tiger, Aravind Adiga
Sundiver (The Uplift Saga, #1), David Brin
Beggars in Spain, Nancy Kress