Search code examples
c++visual-studio-2013noreturn

C3409: empty attribute block is not allowed by noreturn


I get one error C3409: empty attribute block is not allowed from noreturn in VS2013.

Here are code snippets:

#ifndef CPPX_NORETURN
#   define  CPPX_NORETURN [[noreturn]]
#endif

...

namespace std {
    class nested_exception
    {
    private:
        exception_ptr nested;

    public:
        CPPX_NORETURN      // error is here
             void rethrow_nested() const
        {
            rethrow_exception(nested);
        }

Could someone help me to figure out how to fix this error? Thanks in advance.


Solution

  • VS2013 doesn't support C++11 attributes feature (VS2015 supported it).

    https://devblogs.microsoft.com/cppblog/c111417-features-in-vs-2015-rtm/

    You can use __declspec(noreturn) instead of [[noreturn]].

    https://msdn.microsoft.com/en-us/library/vstudio/k6ktzx3s%28v=vs.100%29.aspx