Skip to content

Commit 41c052e

Browse files
glankkfirewave
authored andcommitted
Use _WIN32 only to check for windows
1 parent 4cbf3d3 commit 41c052e

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

simplecpp.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
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
@@ -33,7 +36,7 @@
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
24192422
static 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

29462949
class NonExistingFilesCache {
29472950
public:
@@ -2973,14 +2976,14 @@ static NonExistingFilesCache nonExistingFilesCache;
29732976

29742977
static 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

30833086
bool 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

31093112
simplecpp::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

32443247
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)
32453248
{
3246-
#ifdef SIMPLECPP_WINDOWS
3249+
#ifdef _WIN32
32473250
if (dui.clearIncludeCache)
32483251
nonExistingFilesCache.clear();
32493252
#endif

simplecpp.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
#ifndef simplecppH
77
#define simplecppH
88

9-
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
10-
# define SIMPLECPP_WINDOWS
11-
#endif
12-
139
#include <cctype>
1410
#include <cstring>
1511
#include <iosfwd>
@@ -43,7 +39,7 @@
4339
# define SIMPLECPP_LIB
4440
#endif
4541

46-
#ifdef SIMPLECPP_WINDOWS
42+
#ifdef _WIN32
4743
# include <cstdint>
4844
#else
4945
# include <sys/stat.h>
@@ -471,7 +467,7 @@ namespace simplecpp {
471467

472468
private:
473469
struct FileID {
474-
#ifdef SIMPLECPP_WINDOWS
470+
#ifdef _WIN32
475471
struct {
476472
std::uint64_t VolumeSerialNumber;
477473
struct {
@@ -495,7 +491,7 @@ namespace simplecpp {
495491
#endif
496492
struct Hasher {
497493
std::size_t operator()(const FileID &id) const {
498-
#ifdef SIMPLECPP_WINDOWS
494+
#ifdef _WIN32
499495
return static_cast<std::size_t>(id.fileIdInfo.FileId.IdentifierHi ^ id.fileIdInfo.FileId.IdentifierLo ^
500496
id.fileIdInfo.VolumeSerialNumber);
501497
#else

0 commit comments

Comments
 (0)