Workaround for C++11 Attributes (Clang-enhanced C++ Compilers)
Go Up to C++11 Features in the Classic Compiler
Clang-enhanced C++ compilers do not support the C++11 attributes deprecated, final (C++), and noreturn, which previous-generation C++ compilers (BCC32) do support.
This topic explains how to work around the missing deprecated and final (C++) attributes when using Clang-enhanced C++ compilers. There is no workaround for the noreturn attribute.
Workaround for the deprecated attribute
You can use #pragma obsolete
as a workaround for the deprecated attribute. The following is a short example of code for a deprecated function.
In previous-generation C++ compilers:
int f(int a)[[deprecated]]{
//code here
}
In Clang-enhanced C++ compilers:
int f(int a){
#pragma obsolete f
//code here
}
Workaround for the final attribute
In Clang-enhanced C++ compilers, the final
keyword is introduced, providing the same functionality as the C++11 final (C++) attribute.
The following is a short example of using the final
keyword.
In previous-generation C++ compilers:
class A {
virtual int f()[[final]];
};
class B : public A {
int f(); // error, 'f' is marked 'final' and cannot be overridden
};
In Clang-enhanced C++ compilers:
class A {
virtual int f() final;
};
class B : public A {
int f(); //error, declaration of 'f' overrides 'final' function
};