1

Provided two applications on different platforms use protobuf to serialize data structures in/from UDP datagrams by SerializeToArray/ParseFromArray use same .proto definitions with line

 syntax = "proto2";

Should all platform have same version of protobuf library or is there compatibility between v.2 and v.3?

Variants of platforms:

  1. Windows 32-bit applications, statically linked v.2.5, MSVC 2010 (legacy application)
  2. Windows 64-bit applications, statically linked v.3.2, MSVC 2017
  3. Windows 64-bit applications, statically linked v.2.5, MSVC 2017
  4. Linux 64-bit, shared library v.2.4, gcc 4.7 C++11
  5. Linux 64-bit, shared library v.2.5, gcc 8.3 C++14
  6. Linux 64-bit, shared library v.3.2, gcc 8.3 C++14

PS. Is there any difference between 32bit and 64bit too?

Swift - Friday Pie
  • 12,777
  • 2
  • 19
  • 42
  • 1
    Protobuf format does not depend on platform, that would be a disaster. But it does depend on version. – freakish Mar 17 '23 at 07:17
  • @freakish I need more definitive answer that that. Whenever I repeat that to developers, they say "we place `syntax = "proto2";`" there. But then we get odd issues with repeated fields and strings. But as I understand that statement form support means actually a version of library. Which is also quite differently working and built depending on arch\compiler. As I once used to support own in-house protobuf library, I know, maintaining bit and byte order difference, compiler difference and platform difference is a nightmare. – Swift - Friday Pie Mar 17 '23 at 07:21
  • 2
    More likely to be a bug, we'll need a [mre] – Alan Birtles Mar 17 '23 at 07:26
  • @AlanBirtles could be. Mainly appears on MSVC + pb 2.5 side interfacing on wire with with MSVC 2017 side. A `string` if not last in structure "eats" away rest of the message, even while there is no exceptions (with mandatory fields missing), Missing data appears as part of string's buffer. I have working theory that it's do do with fact that modern `std::string` is not zero-terminated (but MSVC one is) – Swift - Friday Pie Mar 17 '23 at 07:39
  • I think pretty much every implementation of `std::string` is null terminated and is now basically [mandated by the standard](https://en.cppreference.com/w/cpp/string/basic_string/data) – Alan Birtles Mar 17 '23 at 07:42
  • @AlanBirtles modifying `.data()` with a set of chars containing zero byte still yields a string with a zero in center, afaik. how that even would work with wide char platform, if practically any unicode\wide char string support is dropped from standard? – Swift - Friday Pie Mar 17 '23 at 07:47
  • Yep, it's always been possible to put nulls in the body of `std::string`, nothing has changed there. Msvc has always worked with nulls (or at least down to VS 2008) – Alan Birtles Mar 17 '23 at 08:12
  • @AlanBirtles can vouch for MSVC 2.0 there (yeah, I worked with THAT). I tried to dig around generated code, really looks like a bug – Swift - Friday Pie Mar 17 '23 at 08:57

0 Answers0