From b3a6f8f53019d1984d4e319db459b11da0663aa3 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 17 Oct 2014 15:51:33 +0200 Subject: More win32 (mxe and vs) build fixes --- libs/ezsat/ezsat.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'libs/ezsat') diff --git a/libs/ezsat/ezsat.cc b/libs/ezsat/ezsat.cc index 54a6e9c7..657bed9d 100644 --- a/libs/ezsat/ezsat.cc +++ b/libs/ezsat/ezsat.cc @@ -22,12 +22,24 @@ #include #include #include +#include #include const int ezSAT::CONST_TRUE = 1; const int ezSAT::CONST_FALSE = 2; +static std::string my_int_to_string(int i) +{ +#ifdef __MINGW32__ + char buffer[64]; + snprintf(buffer, 64, "%d", i); + return buffer; +#else + return std::to_string(i); +#endif +} + ezSAT::ezSAT() { flag_keep_cnf = false; @@ -183,7 +195,7 @@ int ezSAT::expression(OpId op, const std::vector &args) if (expressionsCache.count(myExpr) > 0) { id = expressionsCache.at(myExpr); } else { - id = -(expressions.size() + 1); + id = -(int(expressions.size()) + 1); expressionsCache[myExpr] = id; expressions.push_back(myExpr); } @@ -490,13 +502,13 @@ int ezSAT::bound(int id) const std::string ezSAT::cnfLiteralInfo(int idx) const { - for (size_t i = 0; i < cnfLiteralVariables.size(); i++) { + for (int i = 0; i < int(cnfLiteralVariables.size()); i++) { if (cnfLiteralVariables[i] == idx) return to_string(i+1); if (cnfLiteralVariables[i] == -idx) return "NOT " + to_string(i+1); } - for (size_t i = 0; i < cnfExpressionVariables.size(); i++) { + for (int i = 0; i < int(cnfExpressionVariables.size()); i++) { if (cnfExpressionVariables[i] == idx) return to_string(-i-1); if (cnfExpressionVariables[i] == -idx) @@ -670,9 +682,7 @@ std::vector ezSAT::vec_var(std::string name, int numBits) { std::vector vec; for (int i = 0; i < numBits; i++) { - char buf[64]; - snprintf(buf, 64, " [%d]", i); - vec.push_back(VAR(name + buf)); + vec.push_back(VAR(name + my_int_to_string(i))); } return vec; } @@ -1245,11 +1255,8 @@ static std::string expression2str(const std::pair> #undef X } text += ":"; - for (auto it : data.second) { - char buf[64]; - snprintf(buf, 64, " %d", it); - text += buf; - } + for (auto it : data.second) + text += " " + my_int_to_string(it); return text; } -- cgit v1.2.3