Skip to content

Commit

Permalink
Added JCV_DISABLE_STRUCT_PACKING config define. (#90)
Browse files Browse the repository at this point in the history
This is currently needed for Zig compatibility: ziglang/zig#4754
  • Loading branch information
Srekel authored Dec 8, 2024
1 parent d9bfd6c commit ffbfa64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/jc_voronoi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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_
{
Expand Down Expand Up @@ -185,7 +189,9 @@ struct jcv_diagram_
jcv_point max;
};

#ifndef JCV_DISABLE_STRUCT_PACKING
#pragma pack(pop)
#endif

#ifdef __cplusplus
}
Expand Down Expand Up @@ -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_
{
Expand Down Expand Up @@ -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 )
{
Expand Down
4 changes: 4 additions & 0 deletions src/jc_voronoi_clip.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@

#include "jc_voronoi.h"

#ifndef JCV_DISABLE_STRUCT_PACKING
#pragma pack(push, 1)
#endif

typedef struct jcv_clipping_polygon_
{
jcv_point* points;
int num_points;
} jcv_clipping_polygon;

#ifndef JCV_DISABLE_STRUCT_PACKING
#pragma pack(pop)
#endif


// Convex polygon clip functions
Expand Down

0 comments on commit ffbfa64

Please sign in to comment.