3
3
* Copyright (C) 2016-2023 simplecpp team
4
4
*/
5
5
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
8
10
# define NOMINMAX
11
+ # define WIN32_LEAN_AND_MEAN
9
12
# include < windows.h>
10
13
# undef ERROR
11
14
#endif
33
36
#include < stack>
34
37
#include < stdexcept>
35
38
#include < string>
36
- #ifdef SIMPLECPP_WINDOWS
39
+ #ifdef _WIN32
37
40
# include < mutex>
38
41
#endif
39
42
#include < unordered_map>
@@ -2415,7 +2418,7 @@ namespace simplecpp {
2415
2418
#endif
2416
2419
}
2417
2420
2418
- #ifdef SIMPLECPP_WINDOWS
2421
+ #ifdef _WIN32
2419
2422
static bool isAbsolutePath (const std::string &path)
2420
2423
{
2421
2424
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)
2941
2944
return tok;
2942
2945
}
2943
2946
2944
- #ifdef SIMPLECPP_WINDOWS
2947
+ #ifdef _WIN32
2945
2948
2946
2949
class NonExistingFilesCache {
2947
2950
public:
@@ -2973,14 +2976,14 @@ static NonExistingFilesCache nonExistingFilesCache;
2973
2976
2974
2977
static std::string openHeaderDirect (std::ifstream &f, const std::string &path)
2975
2978
{
2976
- #ifdef SIMPLECPP_WINDOWS
2979
+ #ifdef _WIN32
2977
2980
if (nonExistingFilesCache.contains (path))
2978
2981
return " " ; // file is known not to exist, skip expensive file open call
2979
2982
#endif
2980
2983
f.open (path.c_str ());
2981
2984
if (f.is_open ())
2982
2985
return path;
2983
- #ifdef SIMPLECPP_WINDOWS
2986
+ #ifdef _WIN32
2984
2987
nonExistingFilesCache.add (path);
2985
2988
#endif
2986
2989
return " " ;
@@ -3082,7 +3085,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::
3082
3085
3083
3086
bool simplecpp::FileDataCache::getFileId (const std::string &path, FileID &id)
3084
3087
{
3085
- #ifdef SIMPLECPP_WINDOWS
3088
+ #ifdef _WIN32
3086
3089
HANDLE hFile = CreateFileA (path.c_str (), 0 , FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
3087
3090
3088
3091
if (hFile == INVALID_HANDLE_VALUE)
@@ -3108,7 +3111,7 @@ bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id)
3108
3111
3109
3112
simplecpp::FileDataCache simplecpp::load (const simplecpp::TokenList &rawtokens, std::vector<std::string> &filenames, const simplecpp::DUI &dui, simplecpp::OutputList *outputList, FileDataCache cache)
3110
3113
{
3111
- #ifdef SIMPLECPP_WINDOWS
3114
+ #ifdef _WIN32
3112
3115
if (dui.clearIncludeCache )
3113
3116
nonExistingFilesCache.clear ();
3114
3117
#endif
@@ -3243,7 +3246,7 @@ static std::string getTimeDefine(const struct tm *timep)
3243
3246
3244
3247
void 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)
3245
3248
{
3246
- #ifdef SIMPLECPP_WINDOWS
3249
+ #ifdef _WIN32
3247
3250
if (dui.clearIncludeCache )
3248
3251
nonExistingFilesCache.clear ();
3249
3252
#endif
0 commit comments