win32/windows: add a defensive windows wrapper header

This commit is contained in:
Danny Robson 2018-08-27 14:16:27 +10:00
parent 93f9cb7c0e
commit 300ae9df73
14 changed files with 47 additions and 16 deletions

View File

@ -135,6 +135,7 @@ if (WIN32)
library_win32.cpp
library_win32.hpp
time_win32.cpp
win32/windows.hpp
win32/except.cpp
win32/except.hpp
win32/handle.cpp

View File

@ -11,8 +11,8 @@
#include "debug.hpp"
#include "types.hpp"
#include "win32/except.hpp"
#include "win32/windows.hpp"
#include <windows.h>
#include <dbghelp.h>
#include <ostream>

View File

@ -11,11 +11,11 @@
#include "win32/error.hpp"
#include "win32/handle.hpp"
#include "win32/windows.hpp"
#include "debug.hpp"
#include "except.hpp"
#include <cstdlib>
#include <windows.h>
#include <dbghelp.h>

View File

@ -10,8 +10,8 @@
#include "log.hpp"
#include "win32/except.hpp"
#include "win32/windows.hpp"
#include <windows.h>
#include <iostream>

View File

@ -9,10 +9,10 @@
#include "exe.hpp"
#include "win32/except.hpp"
#include "win32/windows.hpp"
#include <experimental/filesystem>
#include <vector>
#include <windows.h>
///////////////////////////////////////////////////////////////////////////////

2
io.hpp
View File

@ -20,7 +20,7 @@
#include <streambuf>
#ifdef PLATFORM_WIN32
#include <windows.h>
#include "win32/windows.hpp"
#else
#define O_BINARY 0
#endif

View File

@ -10,8 +10,7 @@
#include "debug.hpp"
#include "win32/except.hpp"
#include <windows.h>
#include "win32/windows.hpp"
using cruft::detail::win32::mapped_file;

View File

@ -13,11 +13,11 @@
#include "pointer.hpp"
#include "io.hpp"
#include "win32/handle.hpp"
#include "win32/windows.hpp"
#include "view.hpp"
#include <cstdint>
#include <experimental/filesystem>
#include <windows.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>

View File

@ -9,9 +9,9 @@
#ifndef __UTIL_LIBRARY_WIN32_HPP
#define __UTIL_LIBRARY_WIN32_HPP
#include <cruft/util/cast.hpp>
#include "win32/windows.hpp"
#include <windows.h>
#include <cruft/util/cast.hpp>
#include <experimental/filesystem>

View File

@ -9,11 +9,10 @@
#include "semaphore_win32.hpp"
#include "../win32/except.hpp"
#include "../win32/windows.hpp"
#include "../debug.hpp"
#include <windows.h>
using cruft::thread::semaphore;

View File

@ -10,10 +10,11 @@
#ifndef CRUFT_UTIL_WIN32_EXCEPT_HPP
#define CRUFT_UTIL_WIN32_EXCEPT_HPP
#include "windows.hpp"
#include <stdexcept>
#include <functional>
#include <windows.h>
namespace cruft::win32 {
class error : public std::runtime_error {

View File

@ -6,7 +6,7 @@
* Copyright 2016 Danny Robson <danny@nerdcruft.net>
*/
#include <windows.h>
#include "windows.hpp"
#include "../posix/fd.hpp"

View File

@ -9,9 +9,9 @@
#ifndef __UTIL_WIN32_REGISTRY_HPP
#define __UTIL_WIN32_REGISTRY_HPP
#include "../view.hpp"
#include "windows.hpp"
#include <windows.h>
#include "../view.hpp"
#include <set>
#include <string>

31
win32/windows.hpp Normal file
View File

@ -0,0 +1,31 @@
#pragma once
// include the windows.h header in a way that won't break anything that isn't
// aware of microsoft's propensity to grab large swathes of common terms.
#if defined(_WINDOWS_)
#error "windows headers have already been included"
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// undefine a bunch of conflicting names.
#if defined(near)
#undef near
#endif
#if defined(far)
#undef far
#endif
#if defined(NEAR)
#undef NEAR
#endif
#if defined(FAR)
#undef FAR
#endif
#if defined(OPAQUE)
#undef OPAQUE
#endif