Skip to content

Commit

Permalink
Fix msvc compile
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Nov 29, 2023
1 parent 63b14be commit e51fc54
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Sources/iron/iron_armpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static const int PTR_SIZE = 8;
static uint32_t di; // Decoded index
static uint32_t ei; // Encoded index
static uint32_t bottom; // Decoded bottom
static void *decoded;
static void *encoded;
static uint8_t *decoded;
static uint8_t *encoded;
static uint32_t capacity;
static uint32_t string_length;
static uint32_t array_count;
Expand Down
8 changes: 8 additions & 0 deletions Sources/iron/iron_armpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

#include <stdint.h>

#ifdef __GNUC__
#define PACK(__Declaration__) __Declaration__ __attribute__((__packed__))
#endif

#ifdef _MSC_VER
#define PACK(__Declaration__) __pragma(pack(push, 1)) __Declaration__ __pragma(pack(pop))
#endif

void *armpack_decode(void *encoded, uint32_t len);

void armpack_encode_start(void *encoded);
Expand Down
9 changes: 5 additions & 4 deletions Sources/zui/zui.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <stdbool.h>
#include <stdint.h>
#include "../iron/iron_armpack.h"
#include "../g2/g2.h"

#define ZUI_LAYOUT_VERTICAL 0
Expand Down Expand Up @@ -97,19 +98,19 @@ typedef struct zui_text_extract {
char uncolored[128];
} zui_text_extract_t;

typedef struct zui_coloring {
typedef PACK(struct zui_coloring {
uint32_t color;
char **start;
int start_count;
char *end;
bool separated;
}__attribute__((packed)) zui_coloring_t;
}) zui_coloring_t;

typedef struct zui_text_coloring {
typedef PACK(struct zui_text_coloring {
zui_coloring_t **colorings;
int colorings_count;
uint32_t default_color;
}__attribute__((packed)) zui_text_coloring_t;
}) zui_text_coloring_t;

typedef struct zui {
bool is_scrolling; // Use to limit other activities
Expand Down
21 changes: 11 additions & 10 deletions Sources/zui/zui_nodes.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#pragma once

#include "zui.h"
#include "../iron/iron_armpack.h"

typedef struct zui_canvas_control {
float pan_x;
float pan_y;
float zoom;
} zui_canvas_control_t;

typedef struct zui_node_socket {
typedef PACK(struct zui_node_socket {
int id;
int node_id;
char *name;
Expand All @@ -20,9 +21,9 @@ typedef struct zui_node_socket {
float max;
float precision;
int display;
}__attribute__((packed)) zui_node_socket_t;
}) zui_node_socket_t;

typedef struct zui_node_button {
typedef PACK(struct zui_node_button {
char *name;
char *type;
int output;
Expand All @@ -34,9 +35,9 @@ typedef struct zui_node_button {
float max;
float precision;
float height;
}__attribute__((packed)) zui_node_button_t;
}) zui_node_button_t;

typedef struct zui_node {
typedef PACK(struct zui_node {
int id;
char *name;
char *type;
Expand All @@ -50,25 +51,25 @@ typedef struct zui_node {
zui_node_button_t **buttons;
int buttons_count;
int width; // float width
}__attribute__((packed)) zui_node_t;
}) zui_node_t;

typedef struct zui_node_link {
typedef PACK(struct zui_node_link {
int id;
int from_id;
int from_socket;
int to_id;
int to_socket;
}__attribute__((packed)) zui_node_link_t;
}) zui_node_link_t;

typedef struct zui_node_canvas {
typedef PACK(struct zui_node_canvas {
char *name;
zui_node_t **nodes;
int nodes_capacity; // 128
int nodes_count;
zui_node_link_t **links;
int links_capacity; // 256
int links_count;
}__attribute__((packed)) zui_node_canvas_t;
}) zui_node_canvas_t;

typedef struct zui_nodes {
bool nodes_drag;
Expand Down

0 comments on commit e51fc54

Please sign in to comment.