Skip to content

Commit

Permalink
Fix Ruby build
Browse files Browse the repository at this point in the history
To be honest, this "fix" feels kinda gross. But I'm happy to
discuss other options.

Being as though this struct is for internal use, I didn't want to
expose it in a header.
  • Loading branch information
brianmario committed Jan 4, 2022
1 parent 8595bb2 commit c94969d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
15 changes: 10 additions & 5 deletions src/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c94969d

Please sign in to comment.