mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Use GNU attributes for deprecated
There appears to be a bug in GCC where if you mixed C++ attributes like `[[deprecated]]` with GNU attributes like `__attribute__(())`, you will get a compile error. This can be a problem when using attributes to both set the export (i.e. visibility) of an item and deprecating the same item. This problem has been encountered before. Commit 34b0bba84207a89e8fddfe62e7a1ff30b1b53a18 fixed the problem by using `[[gnu::visibility()]]` instead of `__attribute__()` in the export macros. This works fine for export macros defined by VTK-m headers such as `VTKM_ALWAYS_EXPORT`. Unfortunately, we have little control over the export macros that CMake automatically creates. Rather than rewrite the CMake export code, we go the other way and use `__attribute__()` for all exports _and_ the depreciated attribute.
This commit is contained in:
parent
0a5f5d55c9
commit
8922f600e1
@ -133,7 +133,14 @@
|
||||
// Only actually use the [[deprecated]] attribute if the compiler supports it AND
|
||||
// we know how to suppress deprecations when necessary.
|
||||
#if defined(VTK_M_DEPRECATED_ATTRIBUTE_SUPPORTED) && defined(VTKM_DEPRECATED_SUPPRESS_SUPPORTED)
|
||||
#ifdef VTKM_MSVC
|
||||
#define VTKM_DEPRECATED(...) [[deprecated(VTK_M_DEPRECATED_MAKE_MESSAGE(__VA_ARGS__))]]
|
||||
#else // !MSVC
|
||||
// GCC and other compilers support the C++14 attribute [[deprecated]], but there appears to be a
|
||||
// bug (or other undesirable behavior) where if you mix [[deprecated]] with __attribute__(()) you
|
||||
// get compile errors. To get around this, use __attribute((deprecated)) where supported.
|
||||
#define VTKM_DEPRECATED(...) __attribute__((deprecated(VTK_M_DEPRECATED_MAKE_MESSAGE(__VA_ARGS__))))
|
||||
#endif // !MSVC
|
||||
#else
|
||||
#define VTKM_DEPRECATED(...)
|
||||
#endif
|
||||
|
@ -89,8 +89,8 @@
|
||||
#define VTKM_ALWAYS_EXPORT
|
||||
#define VTKM_NEVER_EXPORT
|
||||
#else
|
||||
#define VTKM_ALWAYS_EXPORT [[gnu::visibility("default")]]
|
||||
#define VTKM_NEVER_EXPORT [[gnu::visibility("hidden")]]
|
||||
#define VTKM_ALWAYS_EXPORT __attribute__((visibility("default")))
|
||||
#define VTKM_NEVER_EXPORT __attribute__((visibility("hidden")))
|
||||
#endif
|
||||
|
||||
// cuda 7.5 doesn't support static const or static constexpr variables
|
||||
|
Loading…
Reference in New Issue
Block a user