From 1f970ae4b823f75ccee7b12838f1635513ddf186 Mon Sep 17 00:00:00 2001 From: Aleksey Nikolaev Date: Wed, 8 Nov 2017 15:30:19 +0300 Subject: [PATCH] Fix undefined reference for strtok_r on MSVC 2015 --- fofi/FoFiType1.cc | 1 + goo/glibc.cc | 9 +++++++++ goo/glibc.h | 4 ++++ goo/glibc_strtok_r.cc | 8 ++++++++ poppler/CharCodeToUnicode.cc | 1 + poppler/GlobalParams.cc | 1 + poppler/PDFDoc.cc | 1 + poppler/UnicodeMap.cc | 1 + 8 files changed, 26 insertions(+) diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc index a07a96c3..52b3c2c2 100644 --- a/fofi/FoFiType1.cc +++ b/fofi/FoFiType1.cc @@ -34,6 +34,7 @@ #include #include #include "goo/gmem.h" +#include "goo/glibc.h" // for strtok_r #include "goo/GooLikely.h" #include "FoFiEncodings.h" #include "FoFiType1.h" diff --git a/goo/glibc.cc b/goo/glibc.cc index 4968047f..ed2af505 100644 --- a/goo/glibc.cc +++ b/goo/glibc.cc @@ -12,6 +12,10 @@ #include "glibc.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef HAVE_GMTIME_R struct tm *gmtime_r(const time_t *timep, struct tm *result) { @@ -55,4 +59,9 @@ time_t timegm(struct tm *tm) t += getLocalTimeZoneOffset(); return t; } + +#ifdef __cplusplus +} +#endif + #endif diff --git a/goo/glibc.h b/goo/glibc.h index 8b372bca..715e4c0b 100644 --- a/goo/glibc.h +++ b/goo/glibc.h @@ -17,7 +17,9 @@ #include +#ifdef __cplusplus extern "C" { +#endif #ifndef HAVE_GMTIME_R struct tm *gmtime_r(const time_t *timep, struct tm *result); @@ -35,7 +37,9 @@ time_t timegm(struct tm *tm); char * strtok_r (char *s, const char *delim, char **save_ptr); #endif +#ifdef __cplusplus } +#endif #endif // GLIBC_H diff --git a/goo/glibc_strtok_r.cc b/goo/glibc_strtok_r.cc index e779bf50..392669c1 100644 --- a/goo/glibc_strtok_r.cc +++ b/goo/glibc_strtok_r.cc @@ -62,6 +62,10 @@ #define __rawmemchr strchr +#ifdef __cplusplus +extern "C" { +#endif + char * strtok_r (char *s, const char *delim, char **save_ptr) { char *token; @@ -92,4 +96,8 @@ char * strtok_r (char *s, const char *delim, char **save_ptr) return token; } +#ifdef __cplusplus +} +#endif + #endif diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc index 10464547..f9d376f6 100644 --- a/poppler/CharCodeToUnicode.cc +++ b/poppler/CharCodeToUnicode.cc @@ -42,6 +42,7 @@ #include "goo/gfile.h" #include "goo/GooLikely.h" #include "goo/GooString.h" +#include "goo/glibc.h" // for strtok_r #include "Error.h" #include "GlobalParams.h" #include "PSTokenizer.h" diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index 26669930..b81187e2 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -65,6 +65,7 @@ #include "goo/GooList.h" #include "goo/GooHash.h" #include "goo/gfile.h" +#include "goo/glibc.h" // for strtok_r #include "Error.h" #include "NameToCharCode.h" #include "CharCodeToUnicode.h" diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index a2468a5f..44264a62 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -60,6 +60,7 @@ #include "goo/gstrtod.h" #include "goo/GooString.h" #include "goo/gfile.h" +#include "goo/glibc.h" // for strtok_r #include "poppler-config.h" #include "GlobalParams.h" #include "Page.h" diff --git a/poppler/UnicodeMap.cc b/poppler/UnicodeMap.cc index 0340ef65..cb3177bf 100644 --- a/poppler/UnicodeMap.cc +++ b/poppler/UnicodeMap.cc @@ -34,6 +34,7 @@ #include "goo/gfile.h" #include "goo/GooString.h" #include "goo/GooList.h" +#include "goo/glibc.h" // for strtok_r #include "Error.h" #include "GlobalParams.h" #include "UnicodeMap.h" -- 2.12.2.windows.2