This constexpr code does not compiled in Visual Studio 2013 version 12.0.21005.1 REL
Is there a newer Visual Studio compiler that works with constexpr?
#include <iostream> constexpr int factorial(int n) { return n <= 1 ? 1 : (n * factorial(n - 1)); } int main(void) { const int fact_three = factorial(3); std::cout << fact_three << std::endl; return 0; }
output from compilation:
1>------ Build started: Project: Project1, Configuration: Debug Win32 ------ 1> Source.cpp 1>....\source.cpp(3): error C2144: syntax error : 'int' should be preceded by ';' 1>....\source.cpp(3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Herb Sutter mentions constexpr on his blog but is unclear in what version it works / will work? http://herbsutter.com/2013/09/09/visual-studio-2013-rc-is-now-available/#comment-13521
Microsoft publishes a C++11 compatibility table, under which constexpr
is clearly marked as not being available in Visual Studio 2013.
The November 2013 CTP has it, though.
Source: Google visual studio constexpr
constexpr
is not supported in Visual Studio 2013 RTM, see the compatibility table. This is not only true for the RTM version, but also for the Visual Studio Updates.
If you want to stick to Visual Studio 2013, you could download the Visual C++ Compiler November 2013 CTP which comes with some new features, see MSDN blog. Unfortunately Microsoft has no merger with the latest Visual Studio Update features and the CTP features and clearly states that they don't plan to do so.
If we want it all, we need to wait for Visual Studio 2015, see the MSDN blog about VS 2015 Preview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With