From: Mikko Rasa Date: Tue, 14 Jun 2016 05:04:42 +0000 (+0300) Subject: Use #ifdef _WIN32 rather than WIN32 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5a32939eb6e576c223e1be5f80226d9e628a2398;p=libs%2Fcore.git Use #ifdef _WIN32 rather than WIN32 It is the proper compiler-defined macro to use. WIN32 is defined by SDK headers and may not appear in all cases. --- diff --git a/source/debug/backtrace.cpp b/source/debug/backtrace.cpp index 1fda155..f9057dc 100644 --- a/source/debug/backtrace.cpp +++ b/source/debug/backtrace.cpp @@ -1,6 +1,6 @@ // Must include something to test for glibc #include -#if !defined(WIN32) && defined(__GLIBC__) +#if !defined(_WIN32) && defined(__GLIBC__) #include #include #endif @@ -14,7 +14,7 @@ namespace Debug { Backtrace Backtrace::create() { -#if !defined(WIN32) && defined(__GLIBC__) +#if !defined(_WIN32) && defined(__GLIBC__) void *addresses[50]; int count = ::backtrace(addresses, 50); diff --git a/source/fs/dir.cpp b/source/fs/dir.cpp index 9c6a97a..717c11c 100644 --- a/source/fs/dir.cpp +++ b/source/fs/dir.cpp @@ -20,7 +20,7 @@ namespace enum { -#ifdef WIN32 +#ifdef _WIN32 ITEMSEP = ';' #else ITEMSEP = ':' @@ -73,7 +73,7 @@ void mkpath(const Path &path, int mode) for(Path::Iterator i=path.begin(); i!=path.end(); ++i) { p /= *i; -#ifdef WIN32 +#ifdef _WIN32 if(p.size()==1 && p.is_absolute()) continue; #endif diff --git a/source/fs/path.cpp b/source/fs/path.cpp index 0fe95d6..d68595b 100644 --- a/source/fs/path.cpp +++ b/source/fs/path.cpp @@ -7,7 +7,7 @@ using namespace std; namespace { -#ifdef WIN32 +#ifdef _WIN32 inline bool is_windows_drive(const std::string &p) { return (p.size()==2 && ((p[0]>='A' && p[0]<='Z') || (p[0]>='a' && p[0]<='z')) && p[1]==':'); } #endif @@ -58,7 +58,7 @@ unsigned Path::size() const bool Path::is_absolute() const { -#ifdef WIN32 +#ifdef _WIN32 if(is_windows_drive((*this)[0])) return true; #endif @@ -103,7 +103,7 @@ void Path::add_component(const string &comp) if(comp.size()==1 && (comp[0]=='/' || comp[0]=='\\')) { // Replace the path with the root directory -#ifdef WIN32 +#ifdef _WIN32 string::size_type slash = (separators.empty() ? string::npos : separators.front()); if(is_windows_drive(path.substr(0, slash))) { @@ -118,7 +118,7 @@ void Path::add_component(const string &comp) separators.push_back(0); } } -#ifdef WIN32 +#ifdef _WIN32 else if(is_windows_drive(comp)) { path = comp; @@ -132,7 +132,7 @@ void Path::add_component(const string &comp) // .. in root directory is a no-op else if(path.size()==1 && path[0]==DIRSEP) ; -#ifdef WIN32 +#ifdef _WIN32 else if(is_windows_drive(path)) ; #endif @@ -192,7 +192,7 @@ string Path::operator[](int n) const bool Path::operator==(const Path &other) const { -#ifdef WIN32 +#ifdef _WIN32 return strcasecmp(path, other.path)==0; #else return path==other.path; @@ -201,7 +201,7 @@ bool Path::operator==(const Path &other) const bool Path::operator<(const Path &other) const { -#ifdef WIN32 +#ifdef _WIN32 return strcasecmp(path, other.path)<0; #else return path(const Path &other) const { -#ifdef WIN32 +#ifdef _WIN32 return strcasecmp(path, other.path)>0; #else return path>other.path; diff --git a/source/fs/path.h b/source/fs/path.h index 3cbfb16..82600dc 100644 --- a/source/fs/path.h +++ b/source/fs/path.h @@ -10,7 +10,7 @@ namespace FS { enum { -#ifdef WIN32 +#ifdef _WIN32 DIRSEP = '\\' #else DIRSEP = '/' diff --git a/source/fs/stat_private.h b/source/fs/stat_private.h index c80d151..7b20638 100644 --- a/source/fs/stat_private.h +++ b/source/fs/stat_private.h @@ -15,7 +15,7 @@ struct Stat::Private Private(const Private &); ~Private(); -#ifndef WIN32 +#ifndef _WIN32 /* This is here because it needs access to private members of Stat, but we can't expose the system stat struct in the public header */ static Stat from_struct_stat(const struct stat &); diff --git a/source/io/file.cpp b/source/io/file.cpp index 666b1ed..1b4a738 100644 --- a/source/io/file.cpp +++ b/source/io/file.cpp @@ -39,7 +39,7 @@ unsigned File::do_write(const char *buf, unsigned size) if(size==0) return 0; -#ifdef WIN32 +#ifdef _WIN32 if(mode&M_APPEND) seek(0, S_END); #endif diff --git a/source/io/poll.cpp b/source/io/poll.cpp index 0356a00..6da777c 100644 --- a/source/io/poll.cpp +++ b/source/io/poll.cpp @@ -36,7 +36,7 @@ void Poller::set_object(EventObject &obj, PollEvent ev) } else if(ev) { -#ifdef WIN32 +#ifdef _WIN32 if(objects.size()>=MAXIMUM_WAIT_OBJECTS) throw logic_error("Maximum number of wait objects reached"); #endif