33 * Copyright (C) 2016-2023 simplecpp team
44 */
55
6- #if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
7- # define _WIN32_WINNT 0x0602
6+ #if defined(_WIN32)
7+ # ifndef _WIN32_WINNT
8+ # define _WIN32_WINNT 0x0602
9+ # endif
810# define NOMINMAX
11+ # define WIN32_LEAN_AND_MEAN
912# include < windows.h>
1013# undef ERROR
1114#endif
3336#include < stack>
3437#include < stdexcept>
3538#include < string>
36- #ifdef SIMPLECPP_WINDOWS
39+ #ifdef _WIN32
3740# include < mutex>
3841#endif
3942#include < unordered_map>
@@ -2415,7 +2418,7 @@ namespace simplecpp {
24152418#endif
24162419}
24172420
2418- #ifdef SIMPLECPP_WINDOWS
2421+ #ifdef _WIN32
24192422static bool isAbsolutePath (const std::string &path)
24202423{
24212424 if (path.length () >= 3 && path[0 ] > 0 && std::isalpha (path[0 ]) && path[1 ] == ' :' && (path[2 ] == ' \\ ' || path[2 ] == ' /' ))
@@ -2941,7 +2944,7 @@ static const simplecpp::Token *gotoNextLine(const simplecpp::Token *tok)
29412944 return tok;
29422945}
29432946
2944- #ifdef SIMPLECPP_WINDOWS
2947+ #ifdef _WIN32
29452948
29462949class NonExistingFilesCache {
29472950public:
@@ -2973,14 +2976,14 @@ static NonExistingFilesCache nonExistingFilesCache;
29732976
29742977static std::string openHeaderDirect (std::ifstream &f, const std::string &path)
29752978{
2976- #ifdef SIMPLECPP_WINDOWS
2979+ #ifdef _WIN32
29772980 if (nonExistingFilesCache.contains (path))
29782981 return " " ; // file is known not to exist, skip expensive file open call
29792982#endif
29802983 f.open (path.c_str ());
29812984 if (f.is_open ())
29822985 return path;
2983- #ifdef SIMPLECPP_WINDOWS
2986+ #ifdef _WIN32
29842987 nonExistingFilesCache.add (path);
29852988#endif
29862989 return " " ;
@@ -3082,7 +3085,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::
30823085
30833086bool simplecpp::FileDataCache::getFileId (const std::string &path, FileID &id)
30843087{
3085- #ifdef SIMPLECPP_WINDOWS
3088+ #ifdef _WIN32
30863089 HANDLE hFile = CreateFileA (path.c_str (), 0 , FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
30873090
30883091 if (hFile == INVALID_HANDLE_VALUE)
@@ -3108,7 +3111,7 @@ bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id)
31083111
31093112simplecpp::FileDataCache simplecpp::load (const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, FileDataCache cache)
31103113{
3111- #ifdef SIMPLECPP_WINDOWS
3114+ #ifdef _WIN32
31123115 if (dui.clearIncludeCache )
31133116 nonExistingFilesCache.clear ();
31143117#endif
@@ -3243,7 +3246,7 @@ static std::string getTimeDefine(const struct tm *timep)
32433246
32443247void simplecpp::preprocess (simplecpp::TokenList &output, const simplecpp::TokenList &rawtokens, std::vector<std::string> &files, simplecpp::FileDataCache &cache, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, std::list<simplecpp::MacroUsage> *macroUsage, std::list<simplecpp::IfCond> *ifCond)
32453248{
3246- #ifdef SIMPLECPP_WINDOWS
3249+ #ifdef _WIN32
32473250 if (dui.clearIncludeCache )
32483251 nonExistingFilesCache.clear ();
32493252#endif
0 commit comments