Skip to content

MinGW compatibility #981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions CPP/Examples/MemLeakTest/MemLeakTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,33 @@ inline Path64 MakeRandomPoly(int width, int height, unsigned vertCnt)
void DoMemoryLeakTest()
{
#ifdef _WIN32
int edge_cnt = 1000;
#ifndef __MINGW32__
int edge_cnt = 1000;

Paths64 subject, clip;
subject.push_back(MakeRandomPoly(800, 600, edge_cnt));
clip.push_back(MakeRandomPoly(800, 600, edge_cnt));
Paths64 subject, clip;
subject.push_back(MakeRandomPoly(800, 600, edge_cnt));
clip.push_back(MakeRandomPoly(800, 600, edge_cnt));

_CrtMemState sOld {}, sNew {}, sDiff {};
_CrtMemCheckpoint(&sOld); //take a snapshot
{
Paths64 solution = Intersect(subject, clip, FillRule::NonZero);
}
_CrtMemCheckpoint(&sNew); //take another snapshot (outside code block)
if (_CrtMemDifference(&sDiff, &sOld, &sNew)) // check for a difference
{
std::cout << std::endl << "Memory leaks!" << std::endl;
//_CrtMemDumpStatistics(&sDiff);
}
else
{
std::cout << std::endl << "No memory leaks detected :)" << std::endl << std::endl;
}
_CrtMemState sOld {}, sNew {}, sDiff {};
_CrtMemCheckpoint(&sOld); //take a snapshot
{
Paths64 solution = Intersect(subject, clip, FillRule::NonZero);
}
_CrtMemCheckpoint(&sNew); //take another snapshot (outside code block)
if (_CrtMemDifference(&sDiff, &sOld, &sNew)) // check for a difference
{
std::cout << std::endl << "Memory leaks!" << std::endl;
//_CrtMemDumpStatistics(&sDiff);
}
else
{
std::cout << std::endl << "No memory leaks detected :)" << std::endl << std::endl;
}
#else
std::cout << "DoMemoryLeakTest only supported with MSVC on Windows - not MinGW." << std::endl << std::endl;
#endif
#else
std::cout << "DoMemoryLeakTest only supported with MSVC on Windows." << std::endl << std::endl;
#endif
}

Expand Down
5 changes: 3 additions & 2 deletions CPP/Utils/ClipFileLoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#include <unistd.h>
#endif

#include <filesystem>

inline bool FileExists(const std::string& name)
{
struct stat buffer;
return (stat(name.c_str(), &buffer) == 0);
return std::filesystem::exists(name);
}

bool LoadTestNum(std::ifstream& source, int test_num,
Expand Down
6 changes: 4 additions & 2 deletions CPP/Utils/clipper.svg.utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <unistd.h>
#endif

#include <filesystem>

namespace Clipper2Lib {

static const unsigned subj_brush_clr = 0x1800009C;
Expand All @@ -27,10 +29,10 @@ namespace Clipper2Lib {
static const unsigned clip_stroke_clr = 0xCCFFA07A;
static const unsigned solution_brush_clr = 0x4466FF66;


inline bool FileExists(const std::string& name)
{
struct stat buffer;
return (stat(name.c_str(), &buffer) == 0);
return std::filesystem::exists(name);
}

inline void SvgAddCaption(SvgWriter& svg, const std::string& caption, int x, int y)
Expand Down