diff --git a/include/box2d/types.h b/include/box2d/types.h index e5b7ad4a..a7052aa0 100644 --- a/include/box2d/types.h +++ b/include/box2d/types.h @@ -13,8 +13,10 @@ #ifdef __cplusplus #define B2_LITERAL(T) T +#define B2_ZERO_INIT {} #else #define B2_LITERAL(T) (T) +#define B2_ZERO_INIT {0} #endif #define B2_ARRAY_COUNT(A) (int)(sizeof(A) / sizeof(A[0])) @@ -177,7 +179,7 @@ typedef struct b2BodyDef { /// The body type: static, kinematic, or dynamic. /// Note: if a dynamic body would have zero mass, the mass is set to one. - enum b2BodyType type; + b2BodyType type; /// The world position of the body. Avoid creating bodies at the origin /// since this can lead to many overlapping shapes. @@ -342,7 +344,7 @@ static inline b2WorldDef b2DefaultWorldDef(void) /// Make a body definition with default values. static inline b2BodyDef b2DefaultBodyDef(void) { - b2BodyDef def = {0}; + b2BodyDef def = B2_ZERO_INIT; def.type = b2_staticBody; def.position = B2_LITERAL(b2Vec2){0.0f, 0.0f}; def.angle = 0.0f; diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 93a601d4..e31c3180 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -12,10 +12,10 @@ add_library( target_include_directories(glad PUBLIC ${GLAD_DIR}/include) # glfw for windowing and input -SET(GLFW_BUILD_DOCS OFF CACHE BOOL "GLFW Docs") -SET(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "GLFW Examples") -SET(GLFW_BUILD_TESTS OFF CACHE BOOL "GLFW Tests") -SET(GLFW_INSTALL OFF CACHE BOOL "GLFW Install") +set(GLFW_BUILD_DOCS OFF CACHE BOOL "GLFW Docs") +set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "GLFW Examples") +set(GLFW_BUILD_TESTS OFF CACHE BOOL "GLFW Tests") +set(GLFW_INSTALL OFF CACHE BOOL "GLFW Install") FetchContent_Declare( glfw @@ -94,6 +94,10 @@ set_target_properties(samples PROPERTIES target_include_directories(samples PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${JSMN_DIR}) target_link_libraries(samples PUBLIC box2d imgui glfw glad enkiTS) +if (${CMAKE_BUILD_TYPE} STREQUAL Debug) + target_compile_definitions(samples PRIVATE _DEBUG) +endif () + # message(STATUS "runtime = ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") # message(STATUS "binary = ${CMAKE_CURRENT_BINARY_DIR}") diff --git a/samples/collection/sample_dynamic_tree.cpp b/samples/collection/sample_dynamic_tree.cpp index 170cb389..6e4e75f2 100644 --- a/samples/collection/sample_dynamic_tree.cpp +++ b/samples/collection/sample_dynamic_tree.cpp @@ -218,7 +218,7 @@ class DynamicTree : public Sample m_startPoint = p; m_endPoint = p; } - else if (mods = GLFW_MOD_SHIFT && m_rayDrag == false) + else if (mods == GLFW_MOD_SHIFT && m_rayDrag == false) { m_queryDrag = true; m_startPoint = p; diff --git a/samples/main.cpp b/samples/main.cpp index a112fbc2..a1da5c66 100644 --- a/samples/main.cpp +++ b/samples/main.cpp @@ -550,7 +550,7 @@ int main(int, char**) // MSAA glfwWindowHint(GLFW_SAMPLES, 4); - sprintf(buffer, "Box2D Version %d.%d.%d Smooth", b2_version.major, b2_version.minor, b2_version.revision); + snprintf(buffer, 128, "Box2D Version %d.%d.%d Smooth", b2_version.major, b2_version.minor, b2_version.revision); if (GLFWmonitor* primaryMonitor = glfwGetPrimaryMonitor()) { @@ -670,7 +670,7 @@ int main(int, char**) if (g_draw.m_showUI) { const SampleEntry& entry = g_sampleEntries[s_settings.m_sampleIndex]; - sprintf(buffer, "%s : %s", entry.category, entry.name); + snprintf(buffer, 128, "%s : %s", entry.category, entry.name); s_sample->DrawTitle(buffer); } @@ -684,13 +684,13 @@ int main(int, char**) // if (g_draw.m_showUI) { - sprintf(buffer, "%.1f ms", 1000.0f * frameTime); + snprintf(buffer, 128, "%.1f ms", 1000.0f * frameTime); ImGui::Begin("Overlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar); ImGui::SetCursorPos(ImVec2(5.0f, g_camera.m_height - 20.0f)); - ImGui::TextColored(ImColor(153, 230, 153, 255), buffer); + ImGui::TextColored(ImColor(153, 230, 153, 255), "%s", buffer); ImGui::End(); } diff --git a/samples/sample.cpp b/samples/sample.cpp index b82c02db..89d71a5c 100644 --- a/samples/sample.cpp +++ b/samples/sample.cpp @@ -279,14 +279,14 @@ void Sample::Step(Settings& settings) int32_t totalCount = 0; char buffer[256] = {0}; - int32_t offset = sprintf_s(buffer, 256, "colors: "); + int32_t offset = snprintf(buffer, 256, "colors: "); for (int32_t i = 0; i < b2_graphColorCount; ++i) { - offset += sprintf_s(buffer + offset, 256 - offset, "%d/", s.colorCounts[i]); + offset += snprintf(buffer + offset, 256 - offset, "%d/", s.colorCounts[i]); totalCount += s.colorCounts[i]; } totalCount += s.colorCounts[b2_graphColorCount]; - sprintf_s(buffer + offset, 256 - offset, "(%d)[%d]", s.colorCounts[b2_graphColorCount], totalCount); + snprintf(buffer + offset, 256 - offset, "(%d)[%d]", s.colorCounts[b2_graphColorCount], totalCount); g_draw.DrawString(5, m_textLine, buffer); m_textLine += m_textIncrement; diff --git a/samples/sample.h b/samples/sample.h index 758ebdb9..2f92f146 100644 --- a/samples/sample.h +++ b/samples/sample.h @@ -17,7 +17,7 @@ struct Settings; -#ifdef _DEBUG +#if defined(_DEBUG) constexpr bool g_sampleDebug = true; #else constexpr bool g_sampleDebug = false; diff --git a/samples/settings.cpp b/samples/settings.cpp index 42d4fcbb..c5541041 100644 --- a/samples/settings.cpp +++ b/samples/settings.cpp @@ -100,7 +100,7 @@ void Settings::Load() int count = tokens[i + 1].end - tokens[i + 1].start; assert(count < 32); const char* s = data + tokens[i + 1].start; - strncpy_s(buffer, 32, s, count); + strncpy(buffer, s, count); char* dummy; m_sampleIndex = strtol(buffer, &dummy, 10); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f6f47d4..fa3a5de0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,7 +90,7 @@ message(STATUS "CMake C compiler: ${CMAKE_C_COMPILER_ID}") message(STATUS "CMake C++ compiler: ${CMAKE_CXX_COMPILER_ID}") message(STATUS "CMake system name: ${CMAKE_SYSTEM_NAME}") -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") +if (MSVC) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # target_compile_options(box2d PRIVATE /W4 /WX) target_compile_options(box2d PRIVATE /W4 /WX /experimental:c11atomics) @@ -101,9 +101,12 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") message(STATUS "CMake using Clang-CL") target_compile_options(box2d PRIVATE /W4 /WX /std:c17 /arch:AVX2) endif() -else() +elseif(LINUX) # FMA -mfma target_compile_options(box2d PRIVATE -Wall -Wextra -Wpedantic -Werror -mavx) +elseif(APPLE) + # enkiTS has some missing (void) on functions + target_compile_options(box2d PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-strict-prototypes) endif() find_library(MATH_LIBRARY m) diff --git a/src/contact_solver.c b/src/contact_solver.c index 2c5f22e0..bd898c08 100644 --- a/src/contact_solver.c +++ b/src/contact_solver.c @@ -11,8 +11,8 @@ #include "world.h" // #include -#include -#include +#include "x86/avx2.h" +#include "x86/fma.h" // Soft constraints with constraint error substepping. Includes a bias removal stage to help remove excess energy. // http://mmacklin.com/smallsteps.pdf @@ -435,14 +435,14 @@ static b2SimdBody b2GatherBodies(const b2SolverBody* restrict bodies, int32_t* r b2FloatW t5 = simde_mm256_unpackhi_ps(b4, b5); b2FloatW t6 = simde_mm256_unpacklo_ps(b6, b7); b2FloatW t7 = simde_mm256_unpackhi_ps(b6, b7); - b2FloatW tt0 = simde_mm256_shuffle_ps(t0, t2, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt1 = simde_mm256_shuffle_ps(t0, t2, _MM_SHUFFLE(3, 2, 3, 2)); - b2FloatW tt2 = simde_mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt3 = simde_mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); - b2FloatW tt4 = simde_mm256_shuffle_ps(t4, t6, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt5 = simde_mm256_shuffle_ps(t4, t6, _MM_SHUFFLE(3, 2, 3, 2)); - b2FloatW tt6 = simde_mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt7 = simde_mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt0 = simde_mm256_shuffle_ps(t0, t2, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt1 = simde_mm256_shuffle_ps(t0, t2, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt2 = simde_mm256_shuffle_ps(t1, t3, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt3 = simde_mm256_shuffle_ps(t1, t3, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt4 = simde_mm256_shuffle_ps(t4, t6, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt5 = simde_mm256_shuffle_ps(t4, t6, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt6 = simde_mm256_shuffle_ps(t5, t7, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt7 = simde_mm256_shuffle_ps(t5, t7, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); b2SimdBody simdBody; simdBody.v.X = simde_mm256_permute2f128_ps(tt0, tt4, 0x20); @@ -470,14 +470,14 @@ static void b2ScatterBodies(b2SolverBody* restrict bodies, int32_t* restrict ind b2FloatW t5 = simde_mm256_unpackhi_ps(simdBody->dp.Y, simdBody->da); b2FloatW t6 = simde_mm256_unpacklo_ps(simdBody->invM, simdBody->invI); b2FloatW t7 = simde_mm256_unpackhi_ps(simdBody->invM, simdBody->invI); - b2FloatW tt0 = simde_mm256_shuffle_ps(t0, t2, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt1 = simde_mm256_shuffle_ps(t0, t2, _MM_SHUFFLE(3, 2, 3, 2)); - b2FloatW tt2 = simde_mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt3 = simde_mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); - b2FloatW tt4 = simde_mm256_shuffle_ps(t4, t6, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt5 = simde_mm256_shuffle_ps(t4, t6, _MM_SHUFFLE(3, 2, 3, 2)); - b2FloatW tt6 = simde_mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(1, 0, 1, 0)); - b2FloatW tt7 = simde_mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt0 = simde_mm256_shuffle_ps(t0, t2, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt1 = simde_mm256_shuffle_ps(t0, t2, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt2 = simde_mm256_shuffle_ps(t1, t3, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt3 = simde_mm256_shuffle_ps(t1, t3, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt4 = simde_mm256_shuffle_ps(t4, t6, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt5 = simde_mm256_shuffle_ps(t4, t6, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); + b2FloatW tt6 = simde_mm256_shuffle_ps(t5, t7, SIMDE_MM_SHUFFLE(1, 0, 1, 0)); + b2FloatW tt7 = simde_mm256_shuffle_ps(t5, t7, SIMDE_MM_SHUFFLE(3, 2, 3, 2)); // I don't use any dummy body in the body array because this will lead to multithreaded sharing and the // associated cache flushing. @@ -771,7 +771,7 @@ void b2SolveContactsSIMD(int32_t startIndex, int32_t endIndex, b2SolverTaskConte b2FloatW s = add(c->separation1, ds); - b2FloatW test = simde_mm256_cmp_ps(s, simde_mm256_setzero_ps(), _CMP_GT_OQ); + b2FloatW test = simde_mm256_cmp_ps(s, simde_mm256_setzero_ps(), SIMDE_CMP_GT_OQ); b2FloatW specBias = mul(s, invDtMul); b2FloatW softBias = simde_mm256_max_ps(mul(biasCoeff, s), minBiasVel); b2FloatW bias = simde_mm256_blendv_ps(softBias, specBias, test); @@ -811,7 +811,7 @@ void b2SolveContactsSIMD(int32_t startIndex, int32_t endIndex, b2SolverTaskConte b2FloatW s = add(c->separation2, ds); - b2FloatW test = simde_mm256_cmp_ps(s, simde_mm256_setzero_ps(), _CMP_GT_OQ); + b2FloatW test = simde_mm256_cmp_ps(s, simde_mm256_setzero_ps(), SIMDE_CMP_GT_OQ); b2FloatW specBias = mul(s, invDtMul); b2FloatW softBias = simde_mm256_max_ps(mul(biasCoeff, s), minBiasVel); b2FloatW bias = simde_mm256_blendv_ps(softBias, specBias, test); @@ -932,8 +932,8 @@ void b2ApplyRestitutionSIMD(int32_t startIndex, int32_t endIndex, b2SolverTaskCo // first point non-penetration constraint { // Set effective mass to zero if restitution should not be applied - b2FloatW test1 = simde_mm256_cmp_ps(add(c->relativeVelocity1, threshold), zero, _CMP_GT_OQ); - b2FloatW test2 = simde_mm256_cmp_ps(c->normalImpulse1, zero, _CMP_EQ_OQ); + b2FloatW test1 = simde_mm256_cmp_ps(add(c->relativeVelocity1, threshold), zero, SIMDE_CMP_GT_OQ); + b2FloatW test2 = simde_mm256_cmp_ps(c->normalImpulse1, zero, SIMDE_CMP_EQ_OQ); b2FloatW test = simde_mm256_or_ps(test1, test2); b2FloatW mass = simde_mm256_blendv_ps(c->normalMass1, zero, test); @@ -966,8 +966,8 @@ void b2ApplyRestitutionSIMD(int32_t startIndex, int32_t endIndex, b2SolverTaskCo // second point non-penetration constraint { // Set effective mass to zero if restitution should not be applied - b2FloatW test1 = simde_mm256_cmp_ps(add(c->relativeVelocity2, threshold), zero, _CMP_GT_OQ); - b2FloatW test2 = simde_mm256_cmp_ps(c->normalImpulse2, zero, _CMP_EQ_OQ); + b2FloatW test1 = simde_mm256_cmp_ps(add(c->relativeVelocity2, threshold), zero, SIMDE_CMP_GT_OQ); + b2FloatW test2 = simde_mm256_cmp_ps(c->normalImpulse2, zero, SIMDE_CMP_EQ_OQ); b2FloatW test = simde_mm256_or_ps(test1, test2); b2FloatW mass = simde_mm256_blendv_ps(c->normalMass2, zero, test); diff --git a/src/graph.c b/src/graph.c index 6a2e71f7..453b2d80 100644 --- a/src/graph.c +++ b/src/graph.c @@ -17,6 +17,8 @@ #include "box2d/aabb.h" +#include "x86/sse2.h" + #include #include #include @@ -918,7 +920,7 @@ static void b2ExecuteMainStage(b2SolverStage* stage, b2SolverTaskContext* contex while (atomic_load(&stage->completionCount) != blockCount) { - _mm_pause(); + simde_mm_pause(); } atomic_store(&stage->completionCount, 0); @@ -1081,7 +1083,7 @@ void b2SolverTask(int32_t startIndex, int32_t endIndex, uint32_t threadIndexDont uint32_t syncBits = atomic_load(&context->syncBits); while (syncBits == lastSyncBits) { - _mm_pause(); + simde_mm_pause(); syncBits = atomic_load(&context->syncBits); } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 16eefa87..15f0b765 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,12 +15,6 @@ set(BOX2D_TESTS add_executable(test ${BOX2D_TESTS}) -if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") - target_compile_options(test PRIVATE /W4 /WX /std:c17) -else() - target_compile_options(test PRIVATE -Wall -Wextra -Wpedantic -Werror) -endif() - # Special access to Box2D internals for testing target_include_directories(test PRIVATE ${CMAKE_SOURCE_DIR}/src) diff --git a/test/main.c b/test/main.c index a59c83cb..67f7e03e 100644 --- a/test/main.c +++ b/test/main.c @@ -18,15 +18,15 @@ //} #endif -extern int BitSetTest(); -extern int MathTest(); -extern int CollisionTest(); -extern int DeterminismTest(); -extern int DistanceTest(); -extern int HelloWorld(); -extern int EmptyWorld(); -extern int ShapeTest(); -extern int TableTest(); +extern int BitSetTest(void); +extern int MathTest(void); +extern int CollisionTest(void); +extern int DeterminismTest(void); +extern int DistanceTest(void); +extern int HelloWorld(void); +extern int EmptyWorld(void); +extern int ShapeTest(void); +extern int TableTest(void); int main(void) { diff --git a/test/test_bitset.c b/test/test_bitset.c index fdec9a0a..4ba8e238 100644 --- a/test/test_bitset.c +++ b/test/test_bitset.c @@ -7,7 +7,7 @@ #define COUNT 169 -int BitSetTest() +int BitSetTest(void) { b2BitSet bitSet = b2CreateBitSet(COUNT); diff --git a/test/test_collision.c b/test/test_collision.c index 2f6e8593..62f7b7ce 100644 --- a/test/test_collision.c +++ b/test/test_collision.c @@ -5,7 +5,7 @@ #include "box2d/math.h" #include "test_macros.h" -static int AABBTest() +static int AABBTest(void) { b2AABB a; a.lowerBound = (b2Vec2){-1.0f, -1.0f}; @@ -30,7 +30,7 @@ static int AABBTest() return 0; } -int CollisionTest() +int CollisionTest(void) { RUN_SUBTEST(AABBTest); diff --git a/test/test_determinism.c b/test/test_determinism.c index 6dac0910..751dfbe1 100644 --- a/test/test_determinism.c +++ b/test/test_determinism.c @@ -188,7 +188,7 @@ void TiltedStacks(int testIndex, int workerCount) } // Test multi-threaded determinism. -int DeterminismTest() +int DeterminismTest(void) { // Test 1 : 4 threads TiltedStacks(0, 16); diff --git a/test/test_distance.c b/test/test_distance.c index 5bcfd899..955bc7bd 100644 --- a/test/test_distance.c +++ b/test/test_distance.c @@ -8,7 +8,7 @@ #include -static int SegmentDistanceTest() +static int SegmentDistanceTest(void) { b2Vec2 p1 = {-1.0f, -1.0f}; b2Vec2 q1 = {-1.0f, 1.0f}; @@ -28,7 +28,7 @@ static int SegmentDistanceTest() return 0; } -static int ShapeDistanceTest() +static int ShapeDistanceTest(void) { b2Vec2 vas[] = { (b2Vec2){-1.0f, -1.0f}, @@ -56,7 +56,7 @@ static int ShapeDistanceTest() return 0; } -static int ShapeCastTest() +static int ShapeCastTest(void) { b2Vec2 vas[] = { (b2Vec2){-1.0f, -1.0f}, @@ -85,7 +85,7 @@ static int ShapeCastTest() return 0; } -static int TimeOfImpactTest() +static int TimeOfImpactTest(void) { b2Vec2 vas[] = { (b2Vec2){-1.0f, -1.0f}, @@ -113,7 +113,7 @@ static int TimeOfImpactTest() return 0; } -int DistanceTest() +int DistanceTest(void) { RUN_SUBTEST(SegmentDistanceTest); RUN_SUBTEST(ShapeDistanceTest); diff --git a/test/test_math.c b/test/test_math.c index fabe10ae..306801a5 100644 --- a/test/test_math.c +++ b/test/test_math.c @@ -6,7 +6,7 @@ #include -int MathTest() +int MathTest(void) { b2Vec2 zero = b2Vec2_zero; b2Vec2 one = {1.0f, 1.0f}; @@ -30,14 +30,14 @@ int MathTest() b2Vec2 u = b2TransformPoint(xf, two); - ENSURE_SMALL(u.x - v.x, FLT_EPSILON); - ENSURE_SMALL(u.y - v.y, FLT_EPSILON); + ENSURE_SMALL(u.x - v.x, 10.0f * FLT_EPSILON); + ENSURE_SMALL(u.y - v.y, 10.0f * FLT_EPSILON); v = b2TransformPoint(xf1, two); v = b2InvTransformPoint(xf1, v); - ENSURE_SMALL(v.x - two.x, 2.0f * FLT_EPSILON); - ENSURE_SMALL(v.y - two.y, 2.0f * FLT_EPSILON); + ENSURE_SMALL(v.x - two.x, 8.0f * FLT_EPSILON); + ENSURE_SMALL(v.y - two.y, 8.0f * FLT_EPSILON); return 0; } diff --git a/test/test_shape.c b/test/test_shape.c index 59d2543d..24d3cc53 100644 --- a/test/test_shape.c +++ b/test/test_shape.c @@ -15,7 +15,7 @@ static b2Segment segment = {{0.0f, 1.0f}, {0.0f, -1.0f}}; #define N 4 -static int ShapeMassTest() +static int ShapeMassTest(void) { { b2MassData md = b2ComputeCircleMass(&circle, 1.0f); @@ -72,7 +72,7 @@ static int ShapeMassTest() return 0; } -static int ShapeAABBTest() +static int ShapeAABBTest(void) { { b2AABB b = b2ComputeCircleAABB(&circle, b2Transform_identity); @@ -101,7 +101,7 @@ static int ShapeAABBTest() return 0; } -static int PointInShapeTest() +static int PointInShapeTest(void) { b2Vec2 p1 = {0.5f, 0.5f}; b2Vec2 p2 = {4.0f, -4.0f}; @@ -125,7 +125,7 @@ static int PointInShapeTest() return 0; } -static int RayCastShapeTest() +static int RayCastShapeTest(void) { b2RayCastInput input = {{-4.0f, 0.0f}, {8.0f, 0.0f}, 1.0f}; @@ -156,7 +156,7 @@ static int RayCastShapeTest() return 0; } -int ShapeTest() +int ShapeTest(void) { box = b2MakeBox(1.0f, 1.0f); diff --git a/test/test_table.c b/test/test_table.c index eb8541f7..80e20bc2 100644 --- a/test/test_table.c +++ b/test/test_table.c @@ -9,7 +9,7 @@ #define ITEM_COUNT ((SET_SPAN * SET_SPAN - SET_SPAN) / 2) -int TableTest() +int TableTest(void) { const int32_t N = SET_SPAN; const uint32_t itemCount = ITEM_COUNT; diff --git a/test/test_world.c b/test/test_world.c index 228e2e5c..463ccd86 100644 --- a/test/test_world.c +++ b/test/test_world.c @@ -13,7 +13,7 @@ // box. // There are no graphics for this example. Box2D is meant to be used // with your rendering engine in your game engine. -int HelloWorld() +int HelloWorld(void) { // Define the gravity vector. b2Vec2 gravity = {0.0f, -10.0f}; @@ -96,7 +96,7 @@ int HelloWorld() return 0; } -int EmptyWorld() +int EmptyWorld(void) { b2WorldDef worldDef = b2DefaultWorldDef(); b2WorldId worldId = b2CreateWorld(&worldDef);