This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 1a00075115 ARROW-16573: [C++][Format] Add canonical include guard for
C Data Interface
1a00075115 is described below
commit 1a00075115ed3487e36281f29c6a7911a7d2bf8d
Author: David Li <[email protected]>
AuthorDate: Tue May 31 16:05:18 2022 +0200
ARROW-16573: [C++][Format] Add canonical include guard for C Data Interface
Follow up from this mailing list discussion: "Arrow C-Data and DuckDB" [1]
Introduce canonical include guards so that the header can be embedded in
other headers safely (some projects/APIs do this for convenience).
[1] https://lists.apache.org/thread/fxrbpo9ywm0yjol9b5zgb04w6tns59qj
Closes #13115 from lidavidm/c-data-interface
Lead-authored-by: David Li <[email protected]>
Co-authored-by: Antoine Pitrou <[email protected]>
Co-authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
---
cpp/src/arrow/c/abi.h | 10 ++++++++++
docs/source/format/CDataInterface.rst | 12 ++++++++++++
docs/source/format/CStreamInterface.rst | 12 ++++++++++++
go/arrow/cdata/arrow/c/abi.h | 10 ++++++++++
java/c/src/main/cpp/abi.h | 10 ++++++++++
5 files changed, 54 insertions(+)
diff --git a/cpp/src/arrow/c/abi.h b/cpp/src/arrow/c/abi.h
index a78170dbdb..aa13cae35b 100644
--- a/cpp/src/arrow/c/abi.h
+++ b/cpp/src/arrow/c/abi.h
@@ -23,6 +23,9 @@
extern "C" {
#endif
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
#define ARROW_FLAG_DICTIONARY_ORDERED 1
#define ARROW_FLAG_NULLABLE 2
#define ARROW_FLAG_MAP_KEYS_SORTED 4
@@ -60,8 +63,13 @@ struct ArrowArray {
void* private_data;
};
+#endif // ARROW_C_DATA_INTERFACE
+
// EXPERIMENTAL: C stream interface
+#ifndef ARROW_C_STREAM_INTERFACE
+#define ARROW_C_STREAM_INTERFACE
+
struct ArrowArrayStream {
// Callback to get the stream type
// (will be the same for all arrays in the stream).
@@ -98,6 +106,8 @@ struct ArrowArrayStream {
void* private_data;
};
+#endif // ARROW_C_STREAM_INTERFACE
+
#ifdef __cplusplus
}
#endif
diff --git a/docs/source/format/CDataInterface.rst
b/docs/source/format/CDataInterface.rst
index 4024720b31..e11692685b 100644
--- a/docs/source/format/CDataInterface.rst
+++ b/docs/source/format/CDataInterface.rst
@@ -255,6 +255,9 @@ are available under the Apache License 2.0.
.. code-block:: c
+ #ifndef ARROW_C_DATA_INTERFACE
+ #define ARROW_C_DATA_INTERFACE
+
#define ARROW_FLAG_DICTIONARY_ORDERED 1
#define ARROW_FLAG_NULLABLE 2
#define ARROW_FLAG_MAP_KEYS_SORTED 4
@@ -292,6 +295,15 @@ are available under the Apache License 2.0.
void* private_data;
};
+ #endif // ARROW_C_DATA_INTERFACE
+
+.. note::
+ The canonical guard ``ARROW_C_DATA_INTERFACE`` is meant to avoid
+ duplicate definitions if two projects copy the C data interface
+ definitions in their own headers, and a third-party project
+ includes from these two projects. It is therefore important that
+ this guard is kept exactly as-is when these definitions are copied.
+
The ArrowSchema structure
-------------------------
diff --git a/docs/source/format/CStreamInterface.rst
b/docs/source/format/CStreamInterface.rst
index d9cd8b8c95..a35f2045c9 100644
--- a/docs/source/format/CStreamInterface.rst
+++ b/docs/source/format/CStreamInterface.rst
@@ -45,6 +45,9 @@ Structure definition
The C stream interface is defined by a single ``struct`` definition::
+ #ifndef ARROW_C_STREAM_INTERFACE
+ #define ARROW_C_STREAM_INTERFACE
+
struct ArrowArrayStream {
// Callbacks providing stream functionality
int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out);
@@ -58,6 +61,15 @@ The C stream interface is defined by a single ``struct``
definition::
void* private_data;
};
+ #endif // ARROW_C_STREAM_INTERFACE
+
+.. note::
+ The canonical guard ``ARROW_C_STREAM_INTERFACE`` is meant to avoid
+ duplicate definitions if two projects copy the C data interface
+ definitions in their own headers, and a third-party project
+ includes from these two projects. It is therefore important that
+ this guard is kept exactly as-is when these definitions are copied.
+
The ArrowArrayStream structure
------------------------------
diff --git a/go/arrow/cdata/arrow/c/abi.h b/go/arrow/cdata/arrow/c/abi.h
index a78170dbdb..aa13cae35b 100644
--- a/go/arrow/cdata/arrow/c/abi.h
+++ b/go/arrow/cdata/arrow/c/abi.h
@@ -23,6 +23,9 @@
extern "C" {
#endif
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
#define ARROW_FLAG_DICTIONARY_ORDERED 1
#define ARROW_FLAG_NULLABLE 2
#define ARROW_FLAG_MAP_KEYS_SORTED 4
@@ -60,8 +63,13 @@ struct ArrowArray {
void* private_data;
};
+#endif // ARROW_C_DATA_INTERFACE
+
// EXPERIMENTAL: C stream interface
+#ifndef ARROW_C_STREAM_INTERFACE
+#define ARROW_C_STREAM_INTERFACE
+
struct ArrowArrayStream {
// Callback to get the stream type
// (will be the same for all arrays in the stream).
@@ -98,6 +106,8 @@ struct ArrowArrayStream {
void* private_data;
};
+#endif // ARROW_C_STREAM_INTERFACE
+
#ifdef __cplusplus
}
#endif
diff --git a/java/c/src/main/cpp/abi.h b/java/c/src/main/cpp/abi.h
index a78170dbdb..aa13cae35b 100644
--- a/java/c/src/main/cpp/abi.h
+++ b/java/c/src/main/cpp/abi.h
@@ -23,6 +23,9 @@
extern "C" {
#endif
+#ifndef ARROW_C_DATA_INTERFACE
+#define ARROW_C_DATA_INTERFACE
+
#define ARROW_FLAG_DICTIONARY_ORDERED 1
#define ARROW_FLAG_NULLABLE 2
#define ARROW_FLAG_MAP_KEYS_SORTED 4
@@ -60,8 +63,13 @@ struct ArrowArray {
void* private_data;
};
+#endif // ARROW_C_DATA_INTERFACE
+
// EXPERIMENTAL: C stream interface
+#ifndef ARROW_C_STREAM_INTERFACE
+#define ARROW_C_STREAM_INTERFACE
+
struct ArrowArrayStream {
// Callback to get the stream type
// (will be the same for all arrays in the stream).
@@ -98,6 +106,8 @@ struct ArrowArrayStream {
void* private_data;
};
+#endif // ARROW_C_STREAM_INTERFACE
+
#ifdef __cplusplus
}
#endif