Skip to content

Commit

Permalink
Use _WIN32 instead of WIN32 to fix Windows builds (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia authored Mar 22, 2021
1 parent 021b799 commit eec3dee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/BC/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <utility>
#include <vector>

#ifndef WIN32
#ifndef _WIN32
# include <sys/stat.h>
# include <unistd.h>
#endif
Expand Down Expand Up @@ -67,15 +67,15 @@ DEFINE_string(
"Colon-separated list of search paths to use when searching for semantics files.");

namespace {
#ifdef WIN32
#ifdef _WIN32
extern "C" std::uint32_t GetProcessId(std::uint32_t handle);
#endif

// We are avoiding the `getpid` name here to make sure we don't
// conflict with the (deprecated) getpid function from the Windows
// ucrt headers
std::uint32_t nativeGetProcessID(void) {
#ifdef WIN32
#ifdef _WIN32
return GetProcessId(0);
#else
return getpid();
Expand Down
12 changes: 6 additions & 6 deletions lib/OS/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <fstream>
#include <vector>

#ifndef WIN32
#ifndef _WIN32
# include <dirent.h>
# include <fcntl.h>
# include <sys/stat.h>
Expand All @@ -47,7 +47,7 @@

// Do not include windows.h, or its macros will end up shadowing our functions
// (i.e.: MoveFile)
#ifdef WIN32
#ifdef _WIN32
namespace {
const std::uint32_t INVALID_FILE_ATTRIBUTES = static_cast<std::uint32_t>(-1);
const std::uint32_t ERROR_NO_MORE_FILES = 18U;
Expand Down Expand Up @@ -119,7 +119,7 @@ int link(const char *path1, const char *path2) {
#endif

namespace remill {
#ifdef WIN32
#ifdef _WIN32
bool IsDirectory(const std::string &path_name) {
auto attributes = GetFileAttributesA(path_name.data());
if (attributes == INVALID_FILE_ATTRIBUTES) {
Expand Down Expand Up @@ -272,15 +272,15 @@ bool RenameFile(const std::string &from_path, const std::string &to_path) {
}
}

#ifndef WIN32
#ifndef _WIN32
namespace {
enum : size_t { kCopyDataSize = 4096ULL };

static uint8_t gCopyData[kCopyDataSize];
} // namespace
#endif

#ifdef WIN32
#ifdef _WIN32
void CopyFile(const std::string &from_path, const std::string &to_path) {
if (CopyFileA(from_path.data(), to_path.data(), false) == 0) {
LOG(FATAL) << "Unable to copy all data read from " << from_path << " to "
Expand Down Expand Up @@ -373,7 +373,7 @@ std::string CanonicalPath(const std::string &path) {

// Returns the path separator character for this OS.
const char *PathSeparator(void) {
#ifdef WIN32
#ifdef _WIN32
return "\\";
#else
return "/";
Expand Down

0 comments on commit eec3dee

Please sign in to comment.