Use C++11 attributes for VTKM_ALWAYS/NEVER_EXPORT

Previously, the `VTKM_ALWAYS_EXPORT` and `VTKM_NEVER_EXPORT` macros
used the gnu-specific `__attribute__` keyword. This change instead
uses the C++11 standard method of using `[[ ]]` as attributes.
Specifically, `__attribute(visibility("---"))` is changed to
`[[gnu::visibility("--")]]`.

The main impetus for this change is that `__attribute__` does not
seem to work with `[[deprecated]]` on GCC compilers. (For sure on
GCC 6. I didn't check all compiler versions.) This change was
recommended from
https://stackoverflow.com/questions/40886628/deprecated-attribute-visibility-default-in-gcc-6-2

This creates a minor backward incompatibility. We have always meant
for these macros to be used before the return type when used with
a function. However, GCC accepted placing `__attribute__` after
the return type. The C++11 `[[ ]]` cannot be placed there, so
some macros might have to be moved. Still, this was a broken
use that happened to work.
This commit is contained in:
Kenneth Moreland 2019-12-05 13:43:33 -05:00
parent cd302effb3
commit 34b0bba842
2 changed files with 13 additions and 9 deletions

@ -26,8 +26,9 @@ namespace internal
{
template <typename WType>
void VTKM_NEVER_EXPORT
TaskTilingSetErrorBuffer(void* w, const vtkm::exec::internal::ErrorMessageBuffer& buffer)
VTKM_NEVER_EXPORT void TaskTilingSetErrorBuffer(
void* w,
const vtkm::exec::internal::ErrorMessageBuffer& buffer)
{
using WorkletType = typename std::remove_cv<WType>::type;
WorkletType* const worklet = static_cast<WorkletType*>(w);
@ -35,7 +36,7 @@ TaskTilingSetErrorBuffer(void* w, const vtkm::exec::internal::ErrorMessageBuffer
}
template <typename WType, typename IType>
void VTKM_NEVER_EXPORT TaskTiling1DExecute(void* w,
VTKM_NEVER_EXPORT void TaskTiling1DExecute(void* w,
void* const v,
vtkm::Id globalIndexOffset,
vtkm::Id start,
@ -63,8 +64,11 @@ void VTKM_NEVER_EXPORT TaskTiling1DExecute(void* w,
}
template <typename FType>
void VTKM_NEVER_EXPORT
FunctorTiling1DExecute(void* f, void* const, vtkm::Id, vtkm::Id start, vtkm::Id end)
VTKM_NEVER_EXPORT void FunctorTiling1DExecute(void* f,
void* const,
vtkm::Id,
vtkm::Id start,
vtkm::Id end)
{
using FunctorType = typename std::remove_cv<FType>::type;
FunctorType const* const functor = static_cast<FunctorType*>(f);
@ -76,7 +80,7 @@ FunctorTiling1DExecute(void* f, void* const, vtkm::Id, vtkm::Id start, vtkm::Id
}
template <typename WType, typename IType>
void VTKM_NEVER_EXPORT TaskTiling3DExecute(void* w,
VTKM_NEVER_EXPORT void TaskTiling3DExecute(void* w,
void* const v,
vtkm::Id globalIndexOffset,
vtkm::Id istart,
@ -108,7 +112,7 @@ void VTKM_NEVER_EXPORT TaskTiling3DExecute(void* w,
}
template <typename FType>
void VTKM_NEVER_EXPORT FunctorTiling3DExecute(void* f,
VTKM_NEVER_EXPORT void FunctorTiling3DExecute(void* f,
void* const,
vtkm::Id,
vtkm::Id istart,

@ -82,8 +82,8 @@
#define VTKM_ALWAYS_EXPORT
#define VTKM_NEVER_EXPORT
#else
#define VTKM_ALWAYS_EXPORT __attribute__((visibility("default")))
#define VTKM_NEVER_EXPORT __attribute__((visibility("hidden")))
#define VTKM_ALWAYS_EXPORT [[gnu::visibility("default")]]
#define VTKM_NEVER_EXPORT [[gnu::visibility("hidden")]]
#endif
// cuda 7.5 doesn't support static const or static constexpr variables