Skip to content

Commit

Permalink
fix: compilation without encoding constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Sep 17, 2024
1 parent 3344da7 commit 362275c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions examples/unix/c11/z_bytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ static void parse_hashmap(kv_pairs_rx_t *kvp, const z_loaned_bytes_t *hashmap);
static void drop_hashmap(kv_pairs_rx_t *kvp);

int main(void) {
// z_owned_encoding_t encoding;
z_owned_bytes_t payload;
z_owned_encoding_t encoding;
(void)encoding;

// Number types: uint8, uint16, uint32, uint64, int8, int16, int32, int64, float, double
uint32_t input_u32 = 123456;
Expand All @@ -65,7 +64,7 @@ int main(void) {
assert(input_u32 == output_u32);
z_drop(z_move(payload));
// Corresponding encoding to be used in operations options like `z_put()`, `z_get()`, etc.
encoding = ENCODING_ZENOH_UINT32;
// encoding = ENCODING_ZENOH_UINT32;

// String, also work with and z_owned_string_t
const char *input_str = "test";
Expand All @@ -76,7 +75,7 @@ int main(void) {
z_drop(z_move(payload));
z_drop(z_move(output_string));
// Corresponding encoding to be used in operations options like `z_put()`, `z_get()`, etc.
encoding = ENCODING_ZENOH_STRING;
// encoding = ENCODING_ZENOH_STRING;

// Bytes, also work with z_owned_slice_t
const uint8_t input_bytes[] = {1, 2, 3, 4};
Expand All @@ -87,7 +86,7 @@ int main(void) {
z_drop(z_move(payload));
z_drop(z_move(output_bytes));
// Corresponding encoding to be used in operations options like `z_put()`, `z_get()`, etc.
encoding = ENCODING_ZENOH_BYTES; // That's the default value
// encoding = ENCODING_ZENOH_BYTES; // That's the default value

// Writer reader
uint8_t input_writer[] = {0, 1, 2, 3, 4};
Expand Down
4 changes: 2 additions & 2 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,11 @@ static int8_t _z_encoding_convert_into_string(const z_loaned_encoding_t *encodin

#else
static int8_t _z_encoding_convert_from_substr(z_owned_encoding_t *encoding, const char *s, size_t len) {
return _z_encoding_make(encoding->_val, _Z_ENCODING_ID_DEFAULT, s, len);
return _z_encoding_make(&encoding->_val, _Z_ENCODING_ID_DEFAULT, s, len);
}

static int8_t _z_encoding_convert_into_string(const z_loaned_encoding_t *encoding, z_owned_string_t *s) {
_z_string_copy(s->_val, &encoding->schema);
_z_string_copy(&s->_val, &encoding->schema);
return _Z_RES_OK;
}

Expand Down

0 comments on commit 362275c

Please sign in to comment.