ruoruoniao opened a new issue, #3746: URL: https://github.com/apache/fory/issues/3746
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/fory/issues) and found no similar issues. ### Version Latest ### Component(s) C++ ### Minimal reproduce step When use a normal struct with `uint32_t`, the type id is `0x0C`, but write data as 8 bytes like `0x01 0x00 0x00 0x00`. ### What did you expect to see? If use `0x0C`, the data should be `0x01`. ### What did you see instead? I see a comment at `Serializer<uint32_t>` and `Serializer<uint64_t>`: ```cpp /// uint32_t serializer - uses VAR_UINT32 to match Rust xlang mode template <> struct Serializer<uint32_t> { ... codes /// uint64_t serializer - uses VAR_UINT64 to match Rust xlang mode template <> struct Serializer<uint64_t> { ... codes ``` But if using a `struct`, in `struct_serializer.h -> write_struct_fields_impl` function, it will walk in branch: ```cpp if constexpr (prim_count == total_count) { ...codes } ``` So it will use `write_primitive_fields_fast` function to write data. It will let `uint32_t` field in `fixed_count`, so it will walk into branch: ```cpp if constexpr (fixed_count > 0 && fixed_bytes > 0) { write_fixed_primitive_fields<T>(obj, buffer, std::make_index_sequence<fixed_count>{}); } ``` So maybe let `uint32_t` as a `varint` when use `FORY_STRUCT`? ### Anything Else? _No response_ ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
