Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
* Copyright (C) 2016-2023 simplecpp team
*/

#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# define _WIN32_WINNT 0x0602
#if defined(_WIN32)
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0602
# endif
# define NOMINMAX
# define WIN32_LEAN_AND_MEAN
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added WIN32_LEAN_AND_MEAN.

# include <windows.h>
# undef ERROR
#endif

#include "simplecpp.h"

#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# define SIMPLECPP_WINDOWS
#endif

#include <algorithm>
#include <cassert>
#include <cctype>
Expand Down Expand Up @@ -3082,7 +3089,7 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::

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

if (hFile == INVALID_HANDLE_VALUE)
Expand Down
10 changes: 3 additions & 7 deletions simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#ifndef simplecppH
#define simplecppH

#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# define SIMPLECPP_WINDOWS
#endif

#include <cctype>
#include <cstring>
#include <iosfwd>
Expand Down Expand Up @@ -43,7 +39,7 @@
# define SIMPLECPP_LIB
#endif

#ifdef SIMPLECPP_WINDOWS
#ifdef _WIN32
# include <cstdint>
#else
# include <sys/stat.h>
Expand Down Expand Up @@ -471,7 +467,7 @@ namespace simplecpp {

private:
struct FileID {
#ifdef SIMPLECPP_WINDOWS
#ifdef _WIN32
struct {
std::uint64_t VolumeSerialNumber;
struct {
Expand All @@ -495,7 +491,7 @@ namespace simplecpp {
#endif
struct Hasher {
std::size_t operator()(const FileID &id) const {
#ifdef SIMPLECPP_WINDOWS
#ifdef _WIN32
return static_cast<std::size_t>(id.fileIdInfo.FileId.IdentifierHi ^ id.fileIdInfo.FileId.IdentifierLo ^
id.fileIdInfo.VolumeSerialNumber);
#else
Expand Down