[x265] [PATCH] strtok_r: fix detection on Windows

Rafaël Carré funman at videolan.org
Mon Apr 7 19:00:39 CEST 2014


Use #ifndef HAVE_STRTOK_R
mingw-w64's pthread.h #defines strtok_r, make sure to undef it
before we use our own definition.
---
 source/common/CMakeLists.txt | 4 +++-
 source/common/param.cpp      | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt
index 09029ba..d78f511 100644
--- a/source/common/CMakeLists.txt
+++ b/source/common/CMakeLists.txt
@@ -130,7 +130,9 @@ if(ENABLE_ASSEMBLY)
 endif(ENABLE_ASSEMBLY)
 
 check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
-set_source_files_properties(param.cpp PROPERTIES COMPILE_FLAGS -DHAVE_STRTOK_R=${HAVE_STRTOK_R})
+if(HAVE_STRTOK_R)
+    set_source_files_properties(param.cpp PROPERTIES COMPILE_FLAGS -DHAVE_STRTOK_R=1)
+endif()
 
 if(GCC AND GCC_HAS_NO_NARROWING)
     set_source_files_properties(cpu.cpp PROPERTIES COMPILE_FLAGS -Wno-narrowing)
diff --git a/source/common/param.cpp b/source/common/param.cpp
index dc97da9..035ef7d 100644
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -37,7 +37,7 @@
 #define strcasecmp _stricmp 
 #endif
 
-#if !HAVE_STROTOK_R
+#ifndef HAVE_STRTOK_R
 /* 
  * adapted from public domain strtok_r() by Charlie Gordon
  *
@@ -49,6 +49,7 @@
  *      http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c
  */
 
+#undef strtok_r
 char* strtok_r(
     char *str, 
     const char *delim, 
-- 
1.9.1



More information about the x265-devel mailing list