Opened 8 years ago
Last modified 5 years ago
#10793 reopened Bugs
Compilation errors in Visual Studio 2013 with /Za (disabled extensions)
Reported by: | Owned by: | Lorenzo Caminiti | |
---|---|---|---|
Milestone: | To Be Determined | Component: | scope_exit |
Version: | Boost 1.65.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Use of Scope Exit generates compilation errors in Visual Studio 2013 (version 18.00.31101 for x86) if /Za
option (disabled language extensions) is used.
I haven't checked other VS versions. I haven't checked previous Boost versions. And /Za
is not set by default (language extensions are enabled by default).
With BOOST_SCOPE_EXIT_ALL
we get following errors:
C:\Users\Adam Badura\Dropbox\Projekty\scope_exit>cl /EHsc /Za /I"C:\Programming\boost_1_57_0" BOOST_SCOPE_EXIT_ALL.cpp Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86 Copyright (C) Microsoft Corporation. All rights reserved. BOOST_SCOPE_EXIT_ALL.cpp C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2143: syntax error : missing ';' before '<' C:\Programming\boost_1_57_0\boost/scope_exit.hpp(427) : see reference to class template instantiation 'boost::scope_exit::aux::msvc_typeof_this::msvc_extract_type<ID,T>' being compiled C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2913: explicit specialization; 'boost::scope_exit::aux::msvc_typeof_this::msvc_extract_type<ID,boost::scope_exit::aux::msvc_typeof_this::msvc_extract_type_default_param>::id2type_impl' is not a specialization of a class template C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2059: syntax error : '<' C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
With BOOST_SCOPE_EXIT
we get following errors:
C:\Users\Adam Badura\Dropbox\Projekty\scope_exit>cl /EHsc /Za /I"C:\Programming\boost_1_57_0" BOOST_SCOPE_EXIT.cpp Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86 Copyright (C) Microsoft Corporation. All rights reserved. BOOST_SCOPE_EXIT.cpp C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2143: syntax error : missing ';' before '<' C:\Programming\boost_1_57_0\boost/scope_exit.hpp(427) : see reference to class template instantiation 'boost::scope_exit::aux::msvc_typeof_this::msvc_extract_type<ID,T>' being compiled C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2913: explicit specialization; 'boost::scope_exit::aux::msvc_typeof_this::msvc_extract_type<ID,boost::scope_exit::aux::msvc_typeof_this::msvc_extract_type_default_param>::id2type_impl' is not a specialization of a class template C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2059: syntax error : '<' C:\Programming\boost_1_57_0\boost/scope_exit.hpp(419) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body BOOST_SCOPE_EXIT.cpp(9) : warning C4003: not enough actual parameters for macro 'BOOST_PP_EXPAND_I'
Note that in case of BOOST_SCOPE_EXIT
we also get warning C4003. And it shows in clean build (without /Za
) as well.
Attachments (2)
Change History (8)
by , 8 years ago
Attachment: | BOOST_SCOPE_EXIT_ALL.cpp added |
---|
comment:1 by , 8 years ago
As for the /Za
compiler option,
don't use
/Za
.
The /Za
option is buggy and its use is not recommended
(or rather, you shouldn't use it).
See the posts from Stephan T. Lavavej (Visual C++ libraries developer)
such as
this.
comment:2 by , 8 years ago
I wasn't aware of that. Good to know! Then the ticket may be closed (rejected or whatever you do) I think.
comment:3 by , 8 years ago
Resolution: | → invalid |
---|---|
Severity: | Problem → Not Applicable |
Status: | new → closed |
Closed as /Za is broken as mentioned in earlier comments.
comment:4 by , 5 years ago
Resolution: | invalid |
---|---|
Severity: | Not Applicable → Problem |
Status: | closed → reopened |
Version: | Boost 1.57.0 → Boost 1.65.0 |
I'm reopening this issue, because the problem also occurs with the new /permissive- option. This is the new and better VC standards compliance mode, and is intended to become the default mode for the compiler in the future.
comment:5 by , 5 years ago
It looks like it can be fixed by changing scope_exit.hpp
thusly:
#if BOOST_MSVC # define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_MSVC_WORKAROUND_01 1 #else # define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_MSVC_WORKAROUND_01 0 #endif
to:
#if BOOST_WORKAROUND(_MSC_VER, < 1910) # define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_MSVC_WORKAROUND_01 1 #else # define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_MSVC_WORKAROUND_01 0 #endif
comment:6 by , 5 years ago
...or possibly :
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) # define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_MSVC_WORKAROUND_01 1 #else # define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_MSVC_WORKAROUND_01 0 #endif
Demonstration program for BOOST_SCOPE_EXIT_ALL