zerodds-idl-c — C99 Codegen

1 Purpose

Emits C99 POD structs plus XCDR2 encoder/decoder/key-hash function pointer tables from an OMG IDL 4.2 source file. Wire-compatible with every other ZeroDDS codegen target (Rust, C++, C#, Java, Python, TS) and with the on-the-wire RTPS 2.5 payload that the runtime ships.

2 Vendor Spec

zerodds-xcdr2-c-1.0 — covers both the C codegen output (§4) and the C-API runtime decoders that consume it (§3).

3 CLI

zerodds-idlc --c -o gen/c chat.idl
# → gen/c/chat.h

One header per .idl file. Module names are flattened to prefixed identifiers (C99 has no namespaces): IDL module Audio { struct Sample {…}; }; becomes C typedef struct Audio_Sample {…} Audio_Sample; plus the matching Audio_Sample_typesupport table.

4 Scope

Implemented:

  • Structs with @final / @appendable / @mutable extensibility
  • Primitive types (boolean, octet, short/long/long long signed and unsigned, float, double)
  • string (unbounded)
  • sequence<T> (unbounded; nested sequences allowed)
  • Nested modules → type-name prefix with ::, identifier prefix with _
  • @key members → key-hash via PlainCdr2BeKeyHolder
  • @id(N) for @mutable

Out of scope for RC1 (returns a codegen error if encountered):

  • Unions, enums, bitsets/bitmasks, typedefs, arrays, maps
  • wstring, fixed, any
  • @optional, @external, @bit_bound

5 Combining with the C runtime

A typical C application links against zerodds-c-api (-lzerodds) and pulls in headers generated by zerodds-idlc --c. The generated *_typesupport table can be registered with the runtime via zerodds_topic_register — the same path C++, C#, and Java bindings use internally.

6 Wiring

6.1 Dependencies

Module path: crates/idl-cpp/src/c_mode.rs. Public API re-exported through zerodds_idl_cpp::{CGenOptions, generate_c_header}.

6.2 Dependents

tools/idlc CLI (--c flag dispatch), crates/zerodds-c-api tests (tests/xcdr2_c_codegen.rs) that verify the generated output round-trips through the runtime decoders.

7 See also

  • zerodds-c-api — the runtime DCPS C FFI
  • idl-cpp — the parent crate hosting both C++ and C-mode emitters
  • idlc — CLI usage and other backend flags
  • /bindings/c-ffi/ — 5-minute Quickstart for the C-API runtime story

zerodds-idl-c — C99-Codegen

1 Zweck

Emittiert C99-POD-Structs plus XCDR2-Encoder/Decoder/Key-Hash-Function- Pointer-Tables aus einer OMG-IDL-4.2-Quelldatei. Wire-kompatibel mit jedem anderen ZeroDDS-Codegen-Target (Rust, C++, C#, Java, Python, TS) und mit dem On-the-Wire-RTPS-2.5-Payload, den die Runtime ausliefert.

2 Vendor-Spec

zerodds-xcdr2-c-1.0 — deckt sowohl die C-Codegen-Ausgabe (§4) als auch die C-API-Runtime-Decoder ab, die sie konsumieren (§3).

3 CLI

zerodds-idlc --c -o gen/c chat.idl
# → gen/c/chat.h

Ein Header pro .idl-Datei. Modul-Namen werden zu präfixierten Identifiern abgeflacht (C99 hat keine Namespaces): IDL module Audio { struct Sample {…}; }; wird zu C typedef struct Audio_Sample {…} Audio_Sample; plus der passenden Audio_Sample_typesupport-Tabelle.

4 Scope

Implementiert:

  • Structs mit @final / @appendable / @mutable-Extensibility
  • Primitive Typen (boolean, octet, short/long/long long signed und unsigned, float, double)
  • string (unbounded)
  • sequence<T> (unbounded; verschachtelte Sequences erlaubt)
  • Verschachtelte Module → Typname-Präfix mit ::, Identifier- Präfix mit _
  • @key-Members → Key-Hash via PlainCdr2BeKeyHolder
  • @id(N) für @mutable

Out-of-Scope für RC1 (gibt einen Codegen-Fehler zurück, wenn angetroffen):

  • Unions, Enums, Bitsets/Bitmasks, Typedefs, Arrays, Maps
  • wstring, fixed, any
  • @optional, @external, @bit_bound

5 Kombination mit der C-Runtime

Eine typische C-Anwendung linkt gegen zerodds-c-api (-lzerodds) und zieht Header rein, die zerodds-idlc --c generiert. Die generierte *_typesupport-Tabelle kann via zerodds_topic_register bei der Runtime registriert werden — derselbe Pfad, den C++-, C#- und Java-Bindings intern nutzen.

6 Wiring

6.1 Dependencies

Modul-Pfad: crates/idl-cpp/src/c_mode.rs. Public-API re-exportiert über zerodds_idl_cpp::{CGenOptions, generate_c_header}.

6.2 Dependents

tools/idlc-CLI (--c-Flag-Dispatch), crates/zerodds-c-api-Tests (tests/xcdr2_c_codegen.rs), die verifizieren, dass die generierte Ausgabe durch die Runtime-Decoder roundtrippt.

7 Siehe auch

  • zerodds-c-api — das Runtime-DCPS-C-FFI
  • idl-cpp — die Parent-Crate, die sowohl C++- als auch C-Mode-Emitter hostet
  • idlc — CLI-Nutzung und weitere Backend-Flags
  • /bindings/c-ffi/ — 5-Minuten-Quickstart für die C-API-Runtime-Story