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-site.git
The following commit(s) were added to refs/heads/main by this push:
new 6806c4592 🔄 synced local 'docs/guide/' with remote 'docs/guide/'
6806c4592 is described below
commit 6806c459233cd2673afabe049156928bd7faddf2
Author: chaokunyang <[email protected]>
AuthorDate: Mon Jan 26 03:06:27 2026 +0000
🔄 synced local 'docs/guide/' with remote 'docs/guide/'
---
docs/guide/cpp/index.md | 9 ++++++---
docs/guide/cpp/supported-types.md | 1 +
docs/guide/cpp/type-registration.md | 1 +
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/docs/guide/cpp/index.md b/docs/guide/cpp/index.md
index fefaef00d..e0bc24a34 100644
--- a/docs/guide/cpp/index.md
+++ b/docs/guide/cpp/index.md
@@ -141,7 +141,7 @@ See the
[examples/cpp](https://github.com/apache/fory/tree/main/examples/cpp) di
using namespace fory::serialization;
// Define a struct
-struct Person {
+class Person {
std::string name;
int32_t age;
std::vector<std::string> hobbies;
@@ -149,10 +149,13 @@ struct Person {
bool operator==(const Person &other) const {
return name == other.name && age == other.age && hobbies == other.hobbies;
}
+
+public:
+ // Register the struct with Fory (FORY_STRUCT must be in public scope).
+ FORY_STRUCT(Person, name, age, hobbies);
};
-// Register the struct with Fory (must be in the same namespace)
-FORY_STRUCT(Person, name, age, hobbies);
+
int main() {
// Create a Fory instance
diff --git a/docs/guide/cpp/supported-types.md
b/docs/guide/cpp/supported-types.md
index fb020e00a..889540c34 100644
--- a/docs/guide/cpp/supported-types.md
+++ b/docs/guide/cpp/supported-types.md
@@ -253,6 +253,7 @@ enum class Color { RED = 0, GREEN = 1, BLUE = 2 };
// Unscoped enum with incontinuous values
enum Priority : int32_t { LOW = -10, NORMAL = 0, HIGH = 10 };
FORY_ENUM(Priority, LOW, NORMAL, HIGH);
+// FORY_ENUM must be defined at namespace scope.
// Usage
Color c = Color::GREEN;
diff --git a/docs/guide/cpp/type-registration.md
b/docs/guide/cpp/type-registration.md
index 79b2d367f..e25618495 100644
--- a/docs/guide/cpp/type-registration.md
+++ b/docs/guide/cpp/type-registration.md
@@ -90,6 +90,7 @@ For enums with non-continuous values, use the `FORY_ENUM`
macro to map values to
// Non-continuous enum values - FORY_ENUM required
enum class Priority { LOW = 10, MEDIUM = 50, HIGH = 100 };
FORY_ENUM(Priority, LOW, MEDIUM, HIGH);
+// FORY_ENUM must be defined at namespace scope.
// Global namespace enum (prefix with ::)
enum LegacyStatus { UNKNOWN = -1, OK = 0, ERROR = 1 };
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]