Reliable detection of strerror_r variants
This commit is contained in:
parent
13c066dbb0
commit
acc9fa012d
@ -27,6 +27,9 @@
|
||||
// Define if you have the strerror_r function.
|
||||
#cmakedefine EXV_HAVE_STRERROR_R
|
||||
|
||||
// Define if the strerror_r function returns char*.
|
||||
#cmakedefine EXV_STRERROR_R_CHAR_P
|
||||
|
||||
// Define to enable the Windows unicode path support.
|
||||
#cmakedefine EXV_UNICODE_PATH
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
include(CheckIncludeFile)
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
# Note that the scope of the EXV_ variables in local
|
||||
if (${EXIV2_ENABLE_WEBREADY})
|
||||
@ -28,6 +29,14 @@ check_function_exists( mmap EXV_HAVE_MMAP )
|
||||
check_function_exists( munmap EXV_HAVE_MUNMAP )
|
||||
check_function_exists( strerror_r EXV_HAVE_STRERROR_R )
|
||||
|
||||
check_cxx_source_compiles( "
|
||||
#include <string.h>
|
||||
int main() {
|
||||
char buff[100];
|
||||
const char* c = strerror_r(0,buff,100);
|
||||
return 0;
|
||||
}" EXV_STRERROR_R_CHAR_P )
|
||||
|
||||
check_include_file( "unistd.h" EXV_HAVE_UNISTD_H )
|
||||
check_include_file( "memory.h" EXV_HAVE_MEMORY_H )
|
||||
check_include_file( "process.h" EXV_HAVE_PROCESS_H )
|
||||
|
||||
@ -53,14 +53,6 @@
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef EXV_HAVE_STRERROR_R
|
||||
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
|
||||
extern char *strerror_r(int errnum, char *buf, size_t n);
|
||||
#else
|
||||
extern int strerror_r(int errnum, char *buf, size_t n);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace Exiv2 {
|
||||
const char* ENVARDEF[] = {"/exiv2.php", "40"}; //!< @brief default URL for http exiv2 handler and time-out
|
||||
const char* ENVARKEY[] = {"EXIV2_HTTP_POST", "EXIV2_TIMEOUT"}; //!< @brief request keys for http exiv2 handler and time-out
|
||||
@ -348,7 +340,7 @@ namespace Exiv2 {
|
||||
std::ostringstream os;
|
||||
#ifdef EXV_HAVE_STRERROR_R
|
||||
const size_t n = 1024;
|
||||
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
|
||||
#ifdef EXV_STRERROR_R_CHAR_P
|
||||
char *buf = 0;
|
||||
char buf2[n];
|
||||
std::memset(buf2, 0x0, n);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user