From d8015fd6ed7664bd178ad3a3c9fd3644c7cfb245 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 29 Aug 2012 23:15:07 +0400 Subject: [PATCH] Fix libjasper build with MSVC --- 3rdparty/libjasper/CMakeLists.txt | 4 ++-- 3rdparty/libjasper/jas_malloc.c | 2 ++ 3rdparty/libjasper/jas_stream.c | 12 ++++++++++++ 3rdparty/libjasper/jasper/jas_stream.h | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/3rdparty/libjasper/CMakeLists.txt b/3rdparty/libjasper/CMakeLists.txt index 5b850c9..0478ef9 100644 --- a/3rdparty/libjasper/CMakeLists.txt +++ b/3rdparty/libjasper/CMakeLists.txt @@ -23,8 +23,8 @@ if(MSVC) add_definitions(-DJAS_WIN_MSVC_BUILD) endif() -ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes -Wmissing-declarations -Wunused -Wshadow -Wsign-compare - /wd4013 /wd4018 /wd4715 /wd4244 /wd4101 /wd4267) +ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes -Wmissing-declarations -Wunused -Wshadow -Wsign-compare) +ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005 if(UNIX) if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) diff --git a/3rdparty/libjasper/jas_malloc.c b/3rdparty/libjasper/jas_malloc.c index 25173af..0982036 100644 --- a/3rdparty/libjasper/jas_malloc.c +++ b/3rdparty/libjasper/jas_malloc.c @@ -78,7 +78,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif #include "jasper/jas_malloc.h" diff --git a/3rdparty/libjasper/jas_stream.c b/3rdparty/libjasper/jas_stream.c index 9b89fa9..c2ba4c8 100644 --- a/3rdparty/libjasper/jas_stream.c +++ b/3rdparty/libjasper/jas_stream.c @@ -363,6 +363,17 @@ jas_stream_t *jas_stream_tmpfile() obj->flags = 0; stream->obj_ = obj; +#ifdef _WIN32 + /* Choose a file name. */ + tmpnam(obj->pathname); + + /* Open the underlying file. */ + if ((obj->fd = open(obj->pathname, O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY, + JAS_STREAM_PERMS)) < 0) { + jas_stream_destroy(stream); + return 0; + } +#else /* Choose a file name. */ snprintf(obj->pathname, L_tmpnam, "%s/tmp.XXXXXXXXXX", P_tmpdir); @@ -371,6 +382,7 @@ jas_stream_t *jas_stream_tmpfile() jas_stream_destroy(stream); return 0; } +#endif /* Unlink the file so that it will disappear if the program terminates abnormally. */ diff --git a/3rdparty/libjasper/jasper/jas_stream.h b/3rdparty/libjasper/jasper/jas_stream.h index f31daa8..a77efa7 100644 --- a/3rdparty/libjasper/jasper/jas_stream.h +++ b/3rdparty/libjasper/jasper/jas_stream.h @@ -252,7 +252,11 @@ typedef struct { typedef struct { int fd; int flags; +#if defined _WIN32 && !defined __MINGW__ && !defined __MINGW32__ + char pathname[MAX_PATH + 1]; +#else char pathname[PATH_MAX + 1]; +#endif } jas_stream_fileobj_t; #define JAS_STREAM_FILEOBJ_DELONCLOSE 0x01 -- 2.7.4