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
911# include < windows.h>
1012# undef ERROR
3335#include < stack>
3436#include < stdexcept>
3537#include < string>
36- #ifdef SIMPLECPP_WINDOWS
38+ #ifdef _WIN32
3739# include < mutex>
3840#endif
3941#include < unordered_map>
@@ -2415,7 +2417,7 @@ namespace simplecpp {
24152417#endif
24162418}
24172419
2418- #ifdef SIMPLECPP_WINDOWS
2420+ #ifdef _WIN32
24192421static bool isAbsolutePath (const std::string &path)
24202422{
24212423 if (path.length () >= 3 && path[0 ] > 0 && std::isalpha (path[0 ]) && path[1 ] == ' :' && (path[2 ] == ' \\ ' || path[2 ] == ' /' ))
@@ -2941,7 +2943,7 @@ static const simplecpp::Token *gotoNextLine(const simplecpp::Token *tok)
29412943 return tok;
29422944}
29432945
2944- #ifdef SIMPLECPP_WINDOWS
2946+ #ifdef _WIN32
29452947
29462948class NonExistingFilesCache {
29472949public:
@@ -2973,14 +2975,14 @@ static NonExistingFilesCache nonExistingFilesCache;
29732975
29742976static std::string openHeaderDirect (std::ifstream &f, const std::string &path)
29752977{
2976- #ifdef SIMPLECPP_WINDOWS
2978+ #ifdef _WIN32
29772979 if (nonExistingFilesCache.contains (path))
29782980 return " " ; // file is known not to exist, skip expensive file open call
29792981#endif
29802982 f.open (path.c_str ());
29812983 if (f.is_open ())
29822984 return path;
2983- #ifdef SIMPLECPP_WINDOWS
2985+ #ifdef _WIN32
29842986 nonExistingFilesCache.add (path);
29852987#endif
29862988 return " " ;
@@ -3082,8 +3084,8 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::
30823084
30833085bool simplecpp::FileDataCache::getFileId (const std::string &path, FileID &id)
30843086{
3085- #ifdef SIMPLECPP_WINDOWS
3086- HANDLE hFile = CreateFileA (path.c_str (), 0 , FILE_SHARE_READ | FILE_SHARE_WRITE, NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
3087+ #ifdef _WIN32
3088+ HANDLE hFile = CreateFileA (path.c_str (), 0 , FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
30873089
30883090 if (hFile == INVALID_HANDLE_VALUE)
30893091 return false ;
@@ -3108,7 +3110,7 @@ bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id)
31083110
31093111simplecpp::FileDataCache simplecpp::load (const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, FileDataCache cache)
31103112{
3111- #ifdef SIMPLECPP_WINDOWS
3113+ #ifdef _WIN32
31123114 if (dui.clearIncludeCache )
31133115 nonExistingFilesCache.clear ();
31143116#endif
@@ -3243,7 +3245,7 @@ static std::string getTimeDefine(const struct tm *timep)
32433245
32443246void 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)
32453247{
3246- #ifdef SIMPLECPP_WINDOWS
3248+ #ifdef _WIN32
32473249 if (dui.clearIncludeCache )
32483250 nonExistingFilesCache.clear ();
32493251#endif
0 commit comments