This extension implements a C++17 generator for Zserio.
Zserio already provides a C++ generator which uses the C++11 standard.
The user experience with the current C++ generator has led to new ideas and enhancements that could improve the usability of the generated code. Additionally, as time flies, users have requested support for the more modern C++17 standard. However, such changes to the generated code would break backward compatibility with existing user applications, which is undesirable. Therefore, this brand new C++17 generator with an incompatible API has been developed.
The following two main features of a C++17 generator offer significant advantages over the current C++ generator:
-
Implementation of the Parameterized Types
New C++17 generator implements Zserio Structures, Choices, and Unions using a new Data View abstraction. This new abstraction naturally solves tge implementation of Parameterized Types without the need for two-phase initialization or custom copy and move constructors.
-
Implementation of the Templates
New C++17 generator implements Zserio templates using C++ native templates. To distinguish which Zserio native type is used as a template argument (e.g. Zserio
bit:5
andbit:7
types are stored in the same C++uint8_t
type), this approach also involves implementing dedicated C++ Zserio types for all Zserio built-in types within the C++ runtime library.
Zserio C++17 generator supports the following platforms:
- 64-bit Linux
- 32-bit Linux
- 64-bit Windows
Zserio C++17 generator supports the following C++ compilers:
- g++ 11.4.0
- clang 14.0.0
- clang 18.1.3
- MinGW 11.2.0
- MSVC 2022
Although newer C++ compilers are not tested, they should work as well as long as they are backward compatible.
The Design Document acts as the primary source of information about the C++17 generator design and is updated regularly.
Current state (10.12.2024):
- The generator fully supports the following Zserio types:
- Enumeration types
- Bitmask types
- Constants
- Structure types
- Choice types
- Union types
- Extended members are not implemented and are always generated as regular compound fields
- Templates are generated as instantiations without usage of native C++ templates
- Offsets, Service Types, Pubsub Types, SQL databases and SQL tables are silently ignored
- No support for generic programming, including JSON export and import
Download the latest Zserio bundle jar (together with Zserio runtime library) from the GitHub action artifacts using the following steps:
- Go to the Actions page
- Click on the latest Linux workflow
- Scroll down to the Artifacts
- Download
zserio-java8
artifact for Zserio bundle jar - Alternatively, download
zserio-runtime-cpp
artifact for Zserio runtime library
Run the Zserio C++17 generator using the following steps:
- Unzip
zserio-java8
to getzserio.jar
binary - Run the command
java -jar zserio.jar schema_name.zs -cpp17 output_directory_name