Skip to content

Commit 6d06551

Browse files
author
Tal Hadad
committed
dumping current directory test
1 parent b25181f commit 6d06551

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

lib/preprocessor.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,29 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const
906906
Certainty::normal));
907907
}
908908

909+
#if defined (__WIN32__)
910+
#define NOMINMAX
911+
#include <Windows.h>
912+
#endif
913+
914+
static std::string currentDirectoryOSCalc_2() {
915+
#if defined (__WIN32__)
916+
TCHAR NPath[MAX_PATH];
917+
GetCurrentDirectory(MAX_PATH, NPath);
918+
#ifdef _UNICODE
919+
// convert the result from TCHAR* to char*
920+
char NPathA[MAX_PATH];
921+
::WideCharToMultiByte(CP_ACP, 0, NPath, lstrlen(NPath), NPathA, MAX_PATH, NULL, NULL);
922+
return NPathA;
923+
#else
924+
// in this case, TCHAR* is just defined to be a char*
925+
return NPath;
926+
#endif
927+
#else
928+
return "";
929+
#endif
930+
}
931+
909932
// Report that include is missing
910933
void Preprocessor::missingInclude(const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType)
911934
{
@@ -917,9 +940,9 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
917940
locationList.emplace_back(filename, linenr, 0);
918941
}
919942
ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information,
920-
(headerType==SystemHeader) ?
943+
((headerType==SystemHeader) ?
921944
"Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results." :
922-
"Include file: \"" + header + "\" not found.",
945+
"Include file: \"" + header + "\" not found.") + " current dir: " + currentDirectoryOSCalc_2(),
923946
(headerType==SystemHeader) ? "missingIncludeSystem" : "missingInclude",
924947
Certainty::normal);
925948
mErrorLogger.reportErr(errmsg);

0 commit comments

Comments
 (0)