Boost logo

Boost :

From: Andreas Huber (ah2003_at_[hidden])
Date: 2003-04-25 18:38:42


Hi there

I compile the following program two times on the newly released MSVC 7.1

#include <boost/shared_ptr.hpp>

int main()
{
  boost::shared_ptr< int > p( new int( 0 ) );
  return 0;
}

once with each of the following compiler switches:

1. /Od /I "..\boost-sandbox" /I "..\boost_1_30_0" /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Za /Zc:wchar_t /Zc:forScope /GR
/Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP

2. /Od /I "..\boost-sandbox" /I "..\boost_1_30_0" /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Zc:wchar_t /Zc:forScope /GR
/Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP

I.e. *identical* settings for a _multithreaded_build_, apart from the
additional /Za (disable language extensions) in 1.

Now comes the interesting part: The shared_ptr compiled with 1 _does_not_
contain a mutex while the shared_ptr compiled with 2 does contain one!!! I
haven't had the time to track down why exactly this happens but my guess is
that MSVC7.1 is taking the /Za switch very seriously and does not define _MT
(a non-ANSI macro) in conformant mode.

I believe quite a few users will compile boost on MSVC 7.1 with /Za, so this
should either be fixed in the config.hpp (don't know whether this is
possible) or the docs should mention this problem.

Has anybody still got the MSVC 7.1 final beta installed? Could you please
try to reproduce this (set a breakpoint on the return statement and see
whether there is a (*(pn.pi_)).mtx_ member in p)? /Za does not work with
7.0, so there's no need to try it there.

Thanks,

Andreas


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk