简体   繁体   中英

Compile error with constexpr functions (visual studio 2015)

I am trying to compile the following piece of code in Visual Studio 2015 (Community version) but encountering the error shown further down below.

/*****Source Code Start*******/
constexpr char const* GetStatusAsCString(Status compute)
{
    switch (compute)
    {
        case armnn::Status::Success: return "Status::Success";
        case armnn::Status::Failure: return "Status::Failure";
        default:                     return "Unknown";
    }
}
/*****Source Code End*******/

Error message:

> Error (active)        a constexpr function must contain exactly one return
> statement ArmNN_MnistTF_64b   c:\armnn\armnn-devenv\armnn\include\armnn\TypesUtils.hpp    22

Note that i have made sure of the following settings:

  1. Set the compiler front end as Clang in VS 2015:

  1. I have set the C++ standard as C++14.

Can anyone please advise me on what else am I missing? Been struggling with this error for sometime now.

Visual Studio 2015 does not fully implement C++14 even as of VS 2015 Update 3 although it has a lot of it.

Specifically, N3652 Extended constexpr is not implemented until VS 2017. You should upgrade to the latest VS 2017 Community edition update (which at this point is 15.7 )

See Visual C++ Language Conformance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM