This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new f15637478 fix(cpp): repair CMake tests and examples (#3699)
f15637478 is described below
commit f156374782aa4d662654811fa1fc0ce37bb16997
Author: Shawn Yang <[email protected]>
AuthorDate: Sat May 23 14:04:58 2026 +0800
fix(cpp): repair CMake tests and examples (#3699)
## Why?
## What does this PR do?
## Related issues
## AI Contribution Checklist
- [ ] Substantial AI assistance was used in this PR: `yes` / `no`
- [ ] If `yes`, I included a completed [AI Contribution
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
in this PR description and the required `AI Usage Disclosure`.
- [ ] If `yes`, my PR description includes the required `ai_review`
summary and screenshot evidence of the final clean AI review results
from both fresh reviewers on the current PR diff or current HEAD after
the latest code changes.
## Does this PR introduce any user-facing change?
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
---
cpp/CMakeLists.txt | 5 ++++-
cpp/fory/meta/CMakeLists.txt | 2 +-
cpp/fory/serialization/CMakeLists.txt | 5 -----
cpp/fory/serialization/array_serializer.h | 24 ++++++++++--------------
cpp/fory/serialization/collection_serializer.h | 22 +++++++++-------------
examples/cpp/hello_row/run.sh | 2 +-
examples/cpp/hello_world/run.sh | 2 +-
7 files changed, 26 insertions(+), 36 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index a2950ff05..c0f4724b6 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -66,7 +66,10 @@ function(fory_configure_target target)
target_compile_options(${target} PRIVATE /arch:AVX2)
endif()
else()
- target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic)
+ target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic
-Wno-unused-parameter)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ target_compile_options(${target} PRIVATE
-Wno-variadic-macro-arguments-omitted)
+ endif()
if(FORY_WARNINGS_AS_ERRORS)
target_compile_options(${target} PRIVATE -Werror)
else()
diff --git a/cpp/fory/meta/CMakeLists.txt b/cpp/fory/meta/CMakeLists.txt
index d75c727d4..f63b98eeb 100644
--- a/cpp/fory/meta/CMakeLists.txt
+++ b/cpp/fory/meta/CMakeLists.txt
@@ -89,6 +89,6 @@ if(FORY_BUILD_TESTS)
add_executable(fory_meta_field_test field_test.cc)
fory_configure_target(fory_meta_field_test)
- target_link_libraries(fory_meta_field_test fory_meta GTest::gtest)
+ target_link_libraries(fory_meta_field_test fory_meta GTest::gtest
GTest::gtest_main)
gtest_discover_tests(fory_meta_field_test)
endif()
diff --git a/cpp/fory/serialization/CMakeLists.txt
b/cpp/fory/serialization/CMakeLists.txt
index f07e61244..bfca6a8b1 100644
--- a/cpp/fory/serialization/CMakeLists.txt
+++ b/cpp/fory/serialization/CMakeLists.txt
@@ -104,11 +104,6 @@ if(FORY_BUILD_TESTS)
target_link_libraries(fory_serialization_variant_test fory_serialization
GTest::gtest GTest::gtest_main)
gtest_discover_tests(fory_serialization_variant_test)
- add_executable(fory_serialization_field_test field_serializer_test.cc)
- fory_configure_target(fory_serialization_field_test)
- target_link_libraries(fory_serialization_field_test fory_serialization
GTest::gtest)
- gtest_discover_tests(fory_serialization_field_test)
-
add_executable(fory_serialization_namespace_macro_test
namespace_macro_test.cc)
fory_configure_target(fory_serialization_namespace_macro_test)
target_link_libraries(fory_serialization_namespace_macro_test
fory_serialization GTest::gtest GTest::gtest_main)
diff --git a/cpp/fory/serialization/array_serializer.h
b/cpp/fory/serialization/array_serializer.h
index aef3851a4..b86976306 100644
--- a/cpp/fory/serialization/array_serializer.h
+++ b/cpp/fory/serialization/array_serializer.h
@@ -114,7 +114,7 @@ struct Serializer<
}
static inline void write_data_generic(const std::array<T, N> &arr,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(arr, ctx);
}
@@ -176,8 +176,7 @@ struct Serializer<
}
static inline std::array<T, N>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
};
@@ -232,7 +231,7 @@ template <size_t N> struct Serializer<std::array<bool, N>> {
}
static inline void write_data_generic(const std::array<bool, N> &arr,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(arr, ctx);
}
@@ -280,8 +279,7 @@ template <size_t N> struct Serializer<std::array<bool, N>> {
}
static inline std::array<bool, N>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
};
@@ -310,7 +308,7 @@ template <size_t N> struct Serializer<std::array<float16_t,
N>> {
static inline void write(const std::array<float16_t, N> &arr,
WriteContext &ctx, RefMode ref_mode, bool
write_type,
- bool has_generics = false) {
+ bool = false) {
write_not_null_ref_flag(ctx, ref_mode);
if (write_type) {
ctx.write_uint8(static_cast<uint8_t>(type_id));
@@ -341,7 +339,7 @@ template <size_t N> struct Serializer<std::array<float16_t,
N>> {
}
static inline void write_data_generic(const std::array<float16_t, N> &arr,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(arr, ctx);
}
@@ -396,8 +394,7 @@ template <size_t N> struct Serializer<std::array<float16_t,
N>> {
}
static inline std::array<float16_t, N>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
};
@@ -423,7 +420,7 @@ template <size_t N> struct
Serializer<std::array<bfloat16_t, N>> {
static inline void write(const std::array<bfloat16_t, N> &arr,
WriteContext &ctx, RefMode ref_mode, bool
write_type,
- bool has_generics = false) {
+ bool = false) {
write_not_null_ref_flag(ctx, ref_mode);
if (write_type) {
ctx.write_uint8(static_cast<uint8_t>(type_id));
@@ -454,7 +451,7 @@ template <size_t N> struct
Serializer<std::array<bfloat16_t, N>> {
}
static inline void write_data_generic(const std::array<bfloat16_t, N> &arr,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(arr, ctx);
}
@@ -509,8 +506,7 @@ template <size_t N> struct
Serializer<std::array<bfloat16_t, N>> {
}
static inline std::array<bfloat16_t, N>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
};
diff --git a/cpp/fory/serialization/collection_serializer.h
b/cpp/fory/serialization/collection_serializer.h
index 06b63f5c6..4856b084b 100644
--- a/cpp/fory/serialization/collection_serializer.h
+++ b/cpp/fory/serialization/collection_serializer.h
@@ -555,8 +555,7 @@ struct Serializer<
}
static inline void write(const std::vector<T, Alloc> &vec, WriteContext &ctx,
- RefMode ref_mode, bool write_type,
- bool has_generics = false) {
+ RefMode ref_mode, bool write_type, bool = false) {
write_not_null_ref_flag(ctx, ref_mode);
if (write_type) {
ctx.write_uint8(static_cast<uint8_t>(type_id));
@@ -586,7 +585,7 @@ struct Serializer<
}
static inline void write_data_generic(const std::vector<T, Alloc> &vec,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(vec, ctx);
}
@@ -612,8 +611,7 @@ struct Serializer<
}
static inline std::vector<T, Alloc>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
@@ -671,7 +669,7 @@ template <typename Alloc> struct
Serializer<std::vector<float16_t, Alloc>> {
static inline void write(const std::vector<float16_t, Alloc> &vec,
WriteContext &ctx, RefMode ref_mode, bool
write_type,
- bool has_generics = false) {
+ bool = false) {
write_not_null_ref_flag(ctx, ref_mode);
if (write_type) {
ctx.write_uint8(static_cast<uint8_t>(type_id));
@@ -702,7 +700,7 @@ template <typename Alloc> struct
Serializer<std::vector<float16_t, Alloc>> {
static inline void
write_data_generic(const std::vector<float16_t, Alloc> &vec,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(vec, ctx);
}
@@ -727,8 +725,7 @@ template <typename Alloc> struct
Serializer<std::vector<float16_t, Alloc>> {
}
static inline std::vector<float16_t, Alloc>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
@@ -777,7 +774,7 @@ template <typename Alloc> struct
Serializer<std::vector<bfloat16_t, Alloc>> {
static inline void write(const std::vector<bfloat16_t, Alloc> &vec,
WriteContext &ctx, RefMode ref_mode, bool
write_type,
- bool has_generics = false) {
+ bool = false) {
write_not_null_ref_flag(ctx, ref_mode);
if (write_type) {
ctx.write_uint8(static_cast<uint8_t>(type_id));
@@ -808,7 +805,7 @@ template <typename Alloc> struct
Serializer<std::vector<bfloat16_t, Alloc>> {
static inline void
write_data_generic(const std::vector<bfloat16_t, Alloc> &vec,
- WriteContext &ctx, bool has_generics) {
+ WriteContext &ctx, bool) {
write_data(vec, ctx);
}
@@ -833,8 +830,7 @@ template <typename Alloc> struct
Serializer<std::vector<bfloat16_t, Alloc>> {
}
static inline std::vector<bfloat16_t, Alloc>
- read_with_type_info(ReadContext &ctx, RefMode ref_mode,
- const TypeInfo &type_info) {
+ read_with_type_info(ReadContext &ctx, RefMode ref_mode, const TypeInfo &) {
return read(ctx, ref_mode, false);
}
diff --git a/examples/cpp/hello_row/run.sh b/examples/cpp/hello_row/run.sh
index 687470fcb..3b09a0735 100755
--- a/examples/cpp/hello_row/run.sh
+++ b/examples/cpp/hello_row/run.sh
@@ -22,7 +22,7 @@ set -e
pip install cmake
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-BUILD_DIR="${SCRIPT_DIR}/build"
+BUILD_DIR="${SCRIPT_DIR}/cmake-build"
echo "=== Fory C++ Hello Row Example Build Script ==="
echo ""
diff --git a/examples/cpp/hello_world/run.sh b/examples/cpp/hello_world/run.sh
index c6929811d..407b21a80 100755
--- a/examples/cpp/hello_world/run.sh
+++ b/examples/cpp/hello_world/run.sh
@@ -22,7 +22,7 @@ set -e
pip install cmake
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-BUILD_DIR="${SCRIPT_DIR}/build"
+BUILD_DIR="${SCRIPT_DIR}/cmake-build"
echo "=== Fory C++ Hello World Example Build Script ==="
echo ""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]