Permalink
Browse files

make some windows compat fixes

  • Loading branch information...
1 parent dd35e08 commit 8879c4246772bf39daa506281f87ee83e9bf7682 @novas0x2a novas0x2a committed Feb 11, 2009
Showing with 50 additions and 14 deletions.
  1. +3 −1 INSTALLGUIDE
  2. +4 −0 configure.ac
  3. +25 −7 src/vw/Core/Log.cc
  4. +10 −3 src/vw/Core/TerminationHandler.cc
  5. +1 −1 src/vw/Core/Thread.h
  6. +6 −1 src/vw/FileIO/JP2.h
  7. +1 −1 src/vw/Image/PixelTypeInfo.h
View
@@ -127,7 +127,9 @@ configure your project's include file and library search paths
appropriately. Also be sure to configure your project to define the
preprocessor symbol "NOMINMAX" to disable the non-portable Windows
definitions of min() and max() macros, which interfere with the
-standard C++ library functions of the same names.
+standard C++ library functions of the same names. In addition, you
+will need to define the preprocessor symbol "_USE_MATH_DEFINES" to
+ensure that math.h defines constants such as M_PI.
Configuring the Build System
View
@@ -86,6 +86,10 @@ AX_COMMON_OPTIONS
# Does the compiler support introspection?
AX_CHECK_INTROSPECTION
+# Looking for posix headers
+AC_CHECK_HEADERS([unistd.h pwd.h])
+AC_CHECK_FUNCS([getpwuid getpid])
+
# Look for the python stuff
AM_PATH_PYTHON([2.4], [HAVE_PYTHON=yes], [HAVE_PYTHON=no])
AC_PYTHON_DEVEL([HAVE_PYTHON=yes], [HAVE_PYTHON=no])
View
@@ -37,8 +37,21 @@
// C Standard Library headers ( for stat(2) and getpwuid() )
#include <sys/types.h>
#include <sys/stat.h>
+
+#ifdef VW_HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+#ifdef VW_HAVE_PWD_H
#include <pwd.h>
+#endif
+
+#ifdef WIN32
+#define stat _stat
+typedef struct _stat struct_stat;
+#else
+typedef struct stat struct_stat;
+#endif
// Posix time is not fully supported in the version of Boost for RHEL
@@ -205,16 +218,16 @@ void vw::Log::stat_logconf() {
// Check to see if the file has changed. If so, re-read the
// settings.
- struct stat stat_struct;
- if (stat(m_logconf_filename.c_str(), &stat_struct) == 0) {
+ struct_stat statbuf;
+ if (stat(m_logconf_filename.c_str(), &statbuf) == 0) {
#ifdef __APPLE__
- if (stat_struct.st_mtimespec.tv_sec > m_logconf_last_modification) {
- m_logconf_last_modification = stat_struct.st_mtimespec.tv_sec;
+ if (statbuf.st_mtimespec.tv_sec > m_logconf_last_modification) {
+ m_logconf_last_modification = statbuf.st_mtimespec.tv_sec;
reload_logconf_rules();
}
#else // Linux
- if (stat_struct.st_mtime > m_logconf_last_modification) {
- m_logconf_last_modification = stat_struct.st_mtime;
+ if (statbuf.st_mtime > m_logconf_last_modification) {
+ m_logconf_last_modification = statbuf.st_mtime;
reload_logconf_rules();
}
#endif
@@ -224,9 +237,14 @@ void vw::Log::stat_logconf() {
}
void vw::Log::set_default_logconf_filename() {
+ std::string homedir;
+#ifdef VW_HAVE_GETPWUID
struct passwd *pw;
pw = getpwuid( getuid() );
- std::string homedir = pw->pw_dir;
+ homedir = pw->pw_dir;
+#endif
+ if (homedir.empty())
+ homedir = getenv("HOME");
m_logconf_filename = homedir + "/.vw_logconf";
}
@@ -1,6 +1,5 @@
#include <cstdio>
#include <stdexcept>
-#include <unistd.h>
#include <cstdlib>
#include <typeinfo>
@@ -20,6 +19,10 @@
#include <dlfcn.h>
#endif
+#ifdef VW_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include "TerminationHandler.h"
@@ -52,9 +55,13 @@ void vw_terminate()
if (current)
current();
- fprintf(stderr, "terminate() called! If you'd like to connect gdb to this process, use:\n");
+
+ fprintf(stderr, "terminate() called! You can attach a debugger.");
+#ifdef VW_HAVE_GETPID
+ fprintf(stderr, "If you'd like to connect gdb to this process, use:\n");
fprintf(stderr, "gdb ignored %d\n", getpid());
- fprintf(stderr, "Press 'enter' to abort...\n");
+#endif
+ fprintf(stderr, "or press 'enter' to abort...\n");
// It's probably not safe to getchar here, but, given where we are,
// we can't really make it worse...
getchar();
View
@@ -289,7 +289,7 @@ namespace vw {
xt.sec++;
milliseconds -= 1000;
}
- xt.nsec+=int_fast32_t(1e6*milliseconds);
+ xt.nsec+=boost::int_fast32_t(1e6*milliseconds);
boost::thread::sleep(xt);
}
};
View
@@ -31,7 +31,12 @@
#include <list>
#include <iostream>
-#include <arpa/inet.h> // ntohl, htonl
+// ntohl, htonl
+#ifdef WIN32
+#include <winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
#include <boost/algorithm/string.hpp>
@@ -446,7 +446,7 @@ namespace vw {
template <class ChannelT> class PixelLab;
// Forward pixel type declarations for the pixel mask wrapper
- template <class ChildT> class PixelMask;
+ template <class ChildT> struct PixelMask;
// *******************************************************************
// Run-time pixel type manipulation routines.

0 comments on commit 8879c42

Please sign in to comment.