From b1ae4c4c9d002ff23e7cd3b73822fa7e95a66aa9 Mon Sep 17 00:00:00 2001 From: Brian Watling Date: Tue, 29 Aug 2023 23:22:34 -0400 Subject: [PATCH] Compile fixes for C on MSVC --- include/chipmunk/cpMarch.h | 8 ++++++++ include/chipmunk/cpPolyline.h | 8 ++++++++ src/cpBody.c | 6 +++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/chipmunk/cpMarch.h b/include/chipmunk/cpMarch.h index cc1f5c06..53474a51 100644 --- a/include/chipmunk/cpMarch.h +++ b/include/chipmunk/cpMarch.h @@ -1,6 +1,10 @@ // Copyright 2013 Howling Moon Software. All rights reserved. // See http://chipmunk2d.net/legal.php for more information. +#ifdef __cplusplus +extern "C" { +#endif + /// Function type used as a callback from the marching squares algorithm to sample an image function. /// It passes you the point to sample and your context pointer, and you return the density. typedef cpFloat (*cpMarchSampleFunc)(cpVect point, void *data); @@ -26,3 +30,7 @@ CP_EXPORT void cpMarchHard( cpMarchSegmentFunc segment, void *segment_data, cpMarchSampleFunc sample, void *sample_data ); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/include/chipmunk/cpPolyline.h b/include/chipmunk/cpPolyline.h index 9a6ebed3..4dc286be 100644 --- a/include/chipmunk/cpPolyline.h +++ b/include/chipmunk/cpPolyline.h @@ -1,6 +1,10 @@ // Copyright 2013 Howling Moon Software. All rights reserved. // See http://chipmunk2d.net/legal.php for more information. +#ifdef __cplusplus +extern "C" { +#endif + // Polylines are just arrays of vertexes. // They are looped if the first vertex is equal to the last. // cpPolyline structs are intended to be passed by value and destroyed when you are done with them. @@ -68,3 +72,7 @@ CP_EXPORT void cpPolylineSetCollectSegment(cpVect v0, cpVect v1, cpPolylineSet * CP_EXPORT cpPolylineSet *cpPolylineConvexDecomposition(cpPolyline *line, cpFloat tol); #define cpPolylineConvexDecomposition_BETA cpPolylineConvexDecomposition + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/cpBody.c b/src/cpBody.c index 8ad2bc99..4ba4b494 100644 --- a/src/cpBody.c +++ b/src/cpBody.c @@ -103,9 +103,9 @@ cpBodyFree(cpBody *body) #ifdef NDEBUG #define cpAssertSaneBody(body) #else - static void cpv_assert_nan(cpVect v, char *message){cpAssertHard(v.x == v.x && v.y == v.y, message);} - static void cpv_assert_infinite(cpVect v, char *message){cpAssertHard(cpfabs(v.x) != INFINITY && cpfabs(v.y) != INFINITY, message);} - static void cpv_assert_sane(cpVect v, char *message){cpv_assert_nan(v, message); cpv_assert_infinite(v, message);} + static void cpv_assert_nan(cpVect v, const char *message){cpAssertHard(v.x == v.x && v.y == v.y, message);} + static void cpv_assert_infinite(cpVect v, const char *message){cpAssertHard(cpfabs(v.x) != INFINITY && cpfabs(v.y) != INFINITY, message);} + static void cpv_assert_sane(cpVect v, const char *message){cpv_assert_nan(v, message); cpv_assert_infinite(v, message);} static void cpBodySanityCheck(const cpBody *body)