Spaces:
Running
Running
/** | |
* This file provides portable macros for marking declarations | |
* as deprecated. You should generally use C10_DEPRECATED, | |
* except when marking 'using' declarations as deprecated, | |
* in which case you should use C10_DEFINE_DEPRECATED_USING | |
* (due to portability concerns). | |
*/ | |
// Sample usage: | |
// | |
// C10_DEPRECATED void bad_func(); | |
// struct C10_DEPRECATED BadStruct { | |
// ... | |
// }; | |
// NB: __cplusplus doesn't work for MSVC, so for now MSVC always uses | |
// the "__declspec(deprecated)" implementation and not the C++14 | |
// "[[deprecated]]" attribute. We tried enabling "[[deprecated]]" for C++14 on | |
// MSVC, but ran into issues with some older MSVC versions. | |
// TODO Is there some way to implement this? | |
// Sample usage: | |
// | |
// C10_DEFINE_DEPRECATED_USING(BadType, int) | |
// | |
// which is the portable version of | |
// | |
// using BadType [[deprecated]] = int; | |
// technically [[deprecated]] syntax is from c++14 standard, but it works in | |
// many compilers. | |
using TypeName [[deprecated]] = TypeThingy; | |
// neither [[deprecated]] nor __declspec(deprecated) work on nvcc on Windows; | |
// you get the error: | |
// | |
// error: attribute does not apply to any entity | |
// | |
// So we just turn the macro off in this case. | |
using TypeName = TypeThingy; | |
// [[deprecated]] does work in windows without nvcc, though msc doesn't support | |
// `__has_cpp_attribute` when c++14 is supported, otherwise | |
// __declspec(deprecated) is used as the alternative. | |
using TypeName [[deprecated]] = TypeThingy; | |
using TypeName = __declspec(deprecated) TypeThingy; | |
// nvcc has a bug where it doesn't understand __attribute__((deprecated)) | |
// declarations even when the host compiler supports it. We'll only use this gcc | |
// attribute when not cuda, and when using a GCC compiler that doesn't support | |
// the c++14 syntax we checked for above (available in __GNUC__ >= 5) | |
using TypeName __attribute__((deprecated)) = TypeThingy; | |
// using cuda + gcc < 5, neither deprecated syntax is available so turning off. | |
using TypeName = TypeThingy; | |