diff --git a/src/builder.c b/src/builder.c index 1b807eea..265c5d82 100644 --- a/src/builder.c +++ b/src/builder.c @@ -113,11 +113,21 @@ int trilogy_builder_write_uint64(trilogy_builder_t *builder, uint64_t val) return TRILOGY_OK; } +#ifndef TRILOGY_FLOAT_BUF +#define TRILOGY_FLOAT_BUF + typedef union { float f; uint32_t u; } trilogy_float_buf_t; +typedef union { + double d; + uint64_t u; +} trilogy_double_buf_t; + +#endif + int trilogy_builder_write_float(trilogy_builder_t *builder, float val) { trilogy_float_buf_t float_val; @@ -132,11 +142,6 @@ int trilogy_builder_write_float(trilogy_builder_t *builder, float val) return TRILOGY_OK; } -typedef union { - double d; - uint64_t u; -} trilogy_double_buf_t; - int trilogy_builder_write_double(trilogy_builder_t *builder, double val) { trilogy_double_buf_t double_val; diff --git a/src/reader.c b/src/reader.c index dcb49250..07c7ddb5 100644 --- a/src/reader.c +++ b/src/reader.c @@ -95,11 +95,21 @@ int trilogy_reader_get_uint64(trilogy_reader_t *reader, uint64_t *out) return TRILOGY_OK; } +#ifndef TRILOGY_FLOAT_BUF +#define TRILOGY_FLOAT_BUF + typedef union { float f; uint32_t u; } trilogy_float_buf_t; +typedef union { + double d; + uint64_t u; +} trilogy_double_buf_t; + +#endif + int trilogy_reader_get_float(trilogy_reader_t *reader, float *out) { CHECK(4); @@ -116,11 +126,6 @@ int trilogy_reader_get_float(trilogy_reader_t *reader, float *out) return TRILOGY_OK; } -typedef union { - double d; - uint64_t u; -} trilogy_double_buf_t; - int trilogy_reader_get_double(trilogy_reader_t *reader, double *out) { CHECK(8);