From ffbfa6475c97f1bbc74c4b336667f39d83851902 Mon Sep 17 00:00:00 2001 From: Anders Elfgren Date: Sun, 8 Dec 2024 13:02:39 +0100 Subject: [PATCH] Added JCV_DISABLE_STRUCT_PACKING config define. (#90) This is currently needed for Zig compatibility: https://github.com/ziglang/zig/issues/4754 --- src/jc_voronoi.h | 10 ++++++++++ src/jc_voronoi_clip.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/jc_voronoi.h b/src/jc_voronoi.h index 625d142..aad369d 100644 --- a/src/jc_voronoi.h +++ b/src/jc_voronoi.h @@ -45,6 +45,8 @@ extern "C" { #define JCV_EDGE_INTERSECT_THRESHOLD 1.0e-10F #endif +// Also see: JCV_DISABLE_STRUCT_PACKING + typedef JCV_REAL_TYPE jcv_real; typedef struct jcv_point_ jcv_point; @@ -113,7 +115,9 @@ extern int jcv_boxshape_clip(const jcv_clipper* clipper, jcv_edge* e); extern void jcv_boxshape_fillgaps(const jcv_clipper* clipper, jcv_context_internal* allocator, jcv_site* s); +#ifndef JCV_DISABLE_STRUCT_PACKING #pragma pack(push, 1) +#endif struct jcv_point_ { @@ -185,7 +189,9 @@ struct jcv_diagram_ jcv_point max; }; +#ifndef JCV_DISABLE_STRUCT_PACKING #pragma pack(pop) +#endif #ifdef __cplusplus } @@ -337,7 +343,9 @@ static inline jcv_real jcv_point_dist( const jcv_point* pt1, const jcv_point* pt // Structs +#ifndef JCV_DISABLE_STRUCT_PACKING #pragma pack(push, 1) +#endif typedef struct jcv_halfedge_ { @@ -397,7 +405,9 @@ struct jcv_context_internal_ jcv_rect rect; }; +#ifndef JCV_DISABLE_STRUCT_PACKING #pragma pack(pop) +#endif void jcv_diagram_free( jcv_diagram* d ) { diff --git a/src/jc_voronoi_clip.h b/src/jc_voronoi_clip.h index 7f0a608..174ad62 100644 --- a/src/jc_voronoi_clip.h +++ b/src/jc_voronoi_clip.h @@ -6,7 +6,9 @@ #include "jc_voronoi.h" +#ifndef JCV_DISABLE_STRUCT_PACKING #pragma pack(push, 1) +#endif typedef struct jcv_clipping_polygon_ { @@ -14,7 +16,9 @@ typedef struct jcv_clipping_polygon_ int num_points; } jcv_clipping_polygon; +#ifndef JCV_DISABLE_STRUCT_PACKING #pragma pack(pop) +#endif // Convex polygon clip functions