Skip to content

Commit 194f72b

Browse files
committed
524 wip
1 parent 05fa3d7 commit 194f72b

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

.github/workflows/CI-mingw.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ jobs:
4848
# TODO: install mingw-w64-x86_64-make and use mingw32.make instead - currently fails with "Windows Subsystem for Linux has no installed distributions."
4949
install: >-
5050
make
51-
python
52-
python-pytest
51+
${{ matrix.pkg-prefix }}cmake
52+
${{ matrix.pkg-prefix }}python
53+
${{ matrix.pkg-prefix }}python-pytest
5354
5455
- name: install compiler
5556
run: |

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
3737
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
3838

3939
add_compile_options(-Wsuggest-attribute=noreturn)
40-
add_compile_options_safe(-Wuseless-cast)
4140
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
4241
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
4342
# TODO: bump warning level
@@ -57,6 +56,9 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5756
add_compile_options(-Wno-suggest-override -Wno-suggest-destructor-override)
5857
# contradicts -Wcovered-switch-default
5958
add_compile_options(-Wno-switch-default)
59+
# for _WIN32
60+
add_compile_options(-Wno-reserved-macro-identifier)
61+
add_compile_options(-Wno-unused-macros)
6062
# TODO: fix these?
6163
add_compile_options(-Wno-padded -Wno-sign-conversion -Wno-implicit-int-conversion -Wno-shorten-64-to-32 -Wno-shadow-field-in-constructor)
6264

simplecpp.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
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
@@ -33,7 +35,7 @@
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
24192421
static 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

29462948
class NonExistingFilesCache {
29472949
public:
@@ -2973,14 +2975,14 @@ static NonExistingFilesCache nonExistingFilesCache;
29732975

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

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

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

32443246
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)
32453247
{
3246-
#ifdef SIMPLECPP_WINDOWS
3248+
#ifdef _WIN32
32473249
if (dui.clearIncludeCache)
32483250
nonExistingFilesCache.clear();
32493251
#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)