Skip to content

Commit cf7c0e7

Browse files
glankkfirewave
andcommitted
fixed #524 - use CreateFileA() for _WIN32 only (fixes includes not found on MinGW)
Co-authored-by: firewave <[email protected]>
1 parent ad24c6e commit cf7c0e7

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

simplecpp.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
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
1215

1316
#include "simplecpp.h"
1417

18+
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
19+
# define SIMPLECPP_WINDOWS
20+
#endif
21+
1522
#include <algorithm>
1623
#include <cassert>
1724
#include <cctype>
@@ -3082,7 +3089,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::
30823089

30833090
bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id)
30843091
{
3085-
#ifdef SIMPLECPP_WINDOWS
3092+
#ifdef _WIN32
30863093
HANDLE hFile = CreateFileA(path.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
30873094

30883095
if (hFile == INVALID_HANDLE_VALUE)

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)