Skip to content

Commit 7f9f5b1

Browse files
authored
fixed Cppcheck compilation with MSBuild (#257)
1 parent 452996c commit 7f9f5b1

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

simplecpp.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ static bool isOct(const std::string &s)
5858
return s.size()>1 && (s[0]=='0') && (s[1] >= '0') && (s[1] < '8');
5959
}
6060

61-
static bool isStringLiteral(const std::string &s)
61+
// TODO: added an undercore since this conflicts with a function of the same name in utils.h from Cppcheck source when building Cppcheck with MSBuild
62+
static bool isStringLiteral_(const std::string &s)
6263
{
6364
return s.size() > 1 && (s[0]=='\"') && (*s.rbegin()=='\"');
6465
}
6566

66-
static bool isCharLiteral(const std::string &s)
67+
// TODO: added an undercore since this conflicts with a function of the same name in utils.h from Cppcheck source when building Cppcheck with MSBuild
68+
static bool isCharLiteral_(const std::string &s)
6769
{
6870
// char literal patterns can include 'a', '\t', '\000', '\xff', 'abcd', and maybe ''
6971
// This only checks for the surrounding '' but doesn't parse the content.
@@ -1950,7 +1952,7 @@ namespace simplecpp {
19501952
throw invalidHashHash::unexpectedNewline(tok->location, name());
19511953

19521954
bool canBeConcatenatedWithEqual = A->isOneOf("+-*/%&|^") || A->str() == "<<" || A->str() == ">>";
1953-
bool canBeConcatenatedStringOrChar = isStringLiteral(A->str()) || isCharLiteral(A->str());
1955+
bool canBeConcatenatedStringOrChar = isStringLiteral_(A->str()) || isCharLiteral_(A->str());
19541956
if (!A->name && !A->number && A->op != ',' && !A->str().empty() && !canBeConcatenatedWithEqual && !canBeConcatenatedStringOrChar)
19551957
throw invalidHashHash::unexpectedToken(tok->location, name(), A);
19561958

simplecpp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,10 @@ namespace simplecpp {
353353
SIMPLECPP_LIB std::string convertCygwinToWindowsPath(const std::string &cygwinPath);
354354

355355
/** Returns the __STDC_VERSION__ value for a given standard */
356-
SIMPLECPP_LIB static std::string getCStdString(const std::string &std);
356+
SIMPLECPP_LIB std::string getCStdString(const std::string &std);
357357

358358
/** Returns the __cplusplus value for a given standard */
359-
SIMPLECPP_LIB static std::string getCppStdString(const std::string &std);
359+
SIMPLECPP_LIB std::string getCppStdString(const std::string &std);
360360
}
361361

362362
#if (__cplusplus < 201103L) && !defined(__APPLE__)

0 commit comments

Comments
 (0)