Hi,
I'm trying build a very simple test program using ScopeExit (just downloaded
from the link in the review notice:
http://boost-consulting.com/vault/index.php?action=downloadfile&filename=sco
pe_exit-0.04.tar.gz&directory=& ). I'm using a brand new download of Boost
1.34.1 with it. The following code builds and runs fine in release mode in
both VC7.1 and 8.0, but fails to build in debug mode in both versions. I
also tried specifying the BOOST_TYPEOF_COMPLIANT in MSVC7.1 debug but to no
avail - I just get some other errors. I couldn't find any indication of what
would cause this difference between debug/release builds. I tried disabling
optimizations in release mode to check whether this would cause release mode
to fail, too, but it didn't. Any help would be appreciated.
Best regards,
Christian Larsen
Code:
#include <iostream>
#include
int main(int argc, char* argv[])
{
bool commit = false;
BOOST_SCOPE_EXIT( (commit) ) {
if( !commit )
std::cerr << "Not committed!\n";
} BOOST_SCOPE_EXIT_END
//commit = true;
return 0;
}
Building debug mode MSVC 7.1:
Compiling...
ScopeExitTest.cpp
using native typeof
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2513:
'boost::type_of::msvc_typeid_wrapper<ID>::type' : no variable declared
before '='
with
[
ID=5
]
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2039: 'type'
: is not a member of 'operator``global namespace'''
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2440: 'type
cast' : cannot convert from 'long' to
'boost::type_of::msvc_typeid_wrapper<ID>::type'
with
[
ID=5
]
No constructor could take the source type, or constructor overload
resolution was ambiguous
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2146: syntax
error : missing ';' before identifier 'type'
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2065: 'type'
: undeclared identifier
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2146: syntax
error : missing ';' before identifier 'commit_boost_scope_exit_typeof'
[...]
Building debug mode MSVC 7.1 (with BOOST_TYPEOF_COMPLIANT):
Compiling...
ScopeExitTest.cpp
using typeof emulation
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2440: 'type
cast' : cannot convert from 'long' to
'main::commit_boost_scope_exit_nested_typeof'
Source or target has incomplete type
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2143: syntax
error : missing ';' before ':'
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2143: syntax
error : missing ';' before ':'
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2143: syntax
error : missing ';' before '{'
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2039: 'type'
: is not a member of 'operator``global namespace'''
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2513: 'int'
: no variable declared before '='
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2146: syntax
error : missing ';' before identifier 'type'
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2065: 'type'
: undeclared identifier
d:\Development\Misc\ScopeExitTest\ScopeExitTest.cpp(8) : error C2146: syntax
error : missing ';' before identifier 'commit_boost_scope_exit_typeof'
[...]
Building debug mode MSVC 8.0:
Compiling...
ScopeExitTest.cpp
using typeof emulation
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2440:
'<function-style-cast>' : cannot convert from 'long' to
'main::commit_boost_scope_exit_nested_typeof'
Source or target has incomplete type
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2143: syntax
error : missing ';' before ':'
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2143: syntax
error : missing ';' before ':'
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2143: syntax
error : missing ';' before '{'
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2039: 'type'
: is not a member of '`global namespace''
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C4430:
missing type specifier - int assumed. Note: C++ does not support default-int
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2513: 'int'
: no variable declared before '='
d:\development\misc\scopeexittest\scopeexittest.cpp(8) : error C2146: syntax
error : missing ';' before identifier 'type'
[...]