Skip to content

Commit

Permalink
See if __declspec works better for exported friends
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Sep 22, 2022
1 parent aaf3490 commit 8a78d6b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions cpp/src/arrow/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ ARROW_EXPORT void InvalidValueOrDie(const Status& st);
/// arrow::Result<int> CalculateFoo();
/// ```
template <class T>
class [[nodiscard]] Result : // NOLINT(whitespace/braces)
public util::EqualityComparable<Result<T>> {
class [[nodiscard]] Result : public util::EqualityComparable<Result<T>> {
template <typename U>
friend class Result;

Expand Down
5 changes: 2 additions & 3 deletions cpp/src/arrow/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ class ARROW_EXPORT StatusDetail {
///
/// Additionally, if an error occurred, a specific error message is generally
/// attached.
class ARROW_EXPORT [[nodiscard]] Status : // NOLINT(whitespace/braces)
public util::EqualityComparable<Status>,
public util::ToStringOstreamable<Status> {
class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status>,
public util::ToStringOstreamable<Status> {
public:
// Create a success status.
Status() noexcept : state_(NULLPTR) {}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/future.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class ARROW_EXPORT FutureImpl : public std::enable_shared_from_this<FutureImpl>
/// The consumer API allows querying a Future's current state, wait for it
/// to complete, and composing futures with callbacks.
template <typename T>
class [[nodiscard]] Future { // NOLINT(whitespace/braces)
class [[nodiscard]] Future {
public:
using ValueType = T;
using SyncType = typename detail::SyncType<T>::type;
Expand Down
15 changes: 8 additions & 7 deletions cpp/src/arrow/util/visibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#endif

#if defined(__cplusplus) && (defined(__GNUC__) || defined(__clang__))
// Use C++ attribute syntax when possible to avoid GCC parser bug
// Use C++ attribute syntax where possible to avoid GCC parser bug
// (https://stackoverflow.com/questions/57993818/gcc-how-to-combine-attribute-dllexport-and-nodiscard-in-a-struct-de)
#define ARROW_DLLEXPORT [[gnu::dllexport]] // NOLINT(whitespace/braces)
#define ARROW_DLLIMPORT [[gnu::dllimport]] // NOLINT(whitespace/braces)
#define ARROW_DLLEXPORT [[gnu::dllexport]]
#define ARROW_DLLIMPORT [[gnu::dllimport]]
#else
#define ARROW_DLLEXPORT __declspec(dllexport)
#define ARROW_DLLIMPORT __declspec(dllimport)
Expand All @@ -42,11 +42,12 @@
#define ARROW_TEMPLATE_EXPORT
#elif defined(ARROW_EXPORTING)
#define ARROW_EXPORT ARROW_DLLEXPORT
#define ARROW_FRIEND_EXPORT ARROW_DLLEXPORT
// For some reason [[gnu::dllexport]] doesn't work well with friend declarations
#define ARROW_FRIEND_EXPORT __declspec(dllexport)
#define ARROW_TEMPLATE_EXPORT ARROW_DLLEXPORT
#else
#define ARROW_EXPORT ARROW_DLLIMPORT
#define ARROW_FRIEND_EXPORT ARROW_DLLIMPORT
#define ARROW_FRIEND_EXPORT __declspec(dllimport)
#define ARROW_TEMPLATE_EXPORT ARROW_DLLIMPORT
#endif

Expand All @@ -61,10 +62,10 @@

#if defined(__cplusplus) && (defined(__GNUC__) || defined(__clang__))
#ifndef ARROW_EXPORT
#define ARROW_EXPORT [[gnu::visibility("default")]] // NOLINT(whitespace/braces)
#define ARROW_EXPORT [[gnu::visibility("default")]]
#endif
#ifndef ARROW_NO_EXPORT
#define ARROW_NO_EXPORT [[gnu::visibility("default")]] // NOLINT(whitespace/braces)
#define ARROW_NO_EXPORT [[gnu::visibility("default")]]
#endif
#else
// Not C++, or not gcc/clang
Expand Down

0 comments on commit 8a78d6b

Please sign in to comment.