diff --git a/app/actions.cpp b/app/actions.cpp index 479fa997..57945e33 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -26,7 +26,7 @@ // + standard includes #include // for stat() #include // for stat() -#ifdef EXV_HAVE_UNISTD_H +#if __has_include() #include // for stat() #endif diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 581defda..7c6a2258 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -9,9 +9,6 @@ // Define if you require webready support. #cmakedefine EXV_ENABLE_WEBREADY -// Define if you have the header file. -#cmakedefine EXV_HAVE_LIBINTL_H - // Define if you want translation of program messages to the user's native language #cmakedefine EXV_ENABLE_NLS @@ -44,15 +41,6 @@ // Define if you have the munmap function. #cmakedefine EXV_HAVE_MUNMAP -/* Define if you have the header file. */ -#cmakedefine EXV_HAVE_LIBPROC_H - -/* Define if you have the header file. */ -#cmakedefine EXV_HAVE_UNISTD_H - -// Define if you have the header file. -#cmakedefine EXV_HAVE_SYS_MMAN_H - // Define if you have the zlib library. #cmakedefine EXV_HAVE_LIBZ diff --git a/samples/getopt-test.cpp b/samples/getopt-test.cpp index 39aa93cf..719755b4 100644 --- a/samples/getopt-test.cpp +++ b/samples/getopt-test.cpp @@ -26,7 +26,7 @@ // getopt.{cpp|hpp} is not part of libexiv2 #include "getopt.hpp" -#ifdef EXV_HAVE_UNISTD_H +#if __has_include() #include #endif #include @@ -79,7 +79,7 @@ int main(int argc, char** const argv) { int n; -#ifdef EXV_HAVE_UNISTD_H +#if __has_include() std::cout << "standard getopt()" << std::endl; do { n = ::getopt(argc, argv, ::optstring); diff --git a/src/basicio.cpp b/src/basicio.cpp index fdbc5697..c23a47bc 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -11,10 +11,6 @@ #include "image_int.hpp" #include "types.hpp" -// + standard includes -#include // _O_BINARY in FileIo::FileIo -#include // for stat, chmod - #include // for remove, rename #include // for alloc, realloc, free #include // std::memcpy @@ -22,14 +18,18 @@ #include // write the temporary file #include -#ifdef EXV_HAVE_SYS_MMAN_H +// + standard includes +#include // _O_BINARY in FileIo::FileIo +#include // for stat, chmod + +#if __has_include() #include // for mmap and munmap #endif -#ifdef EXV_HAVE_PROCESS_H +#if __has_include() #include #endif -#ifdef EXV_HAVE_UNISTD_H -#include // for getpid, stat +#if __has_include() +#include #endif #ifdef EXV_USE_CURL diff --git a/src/futils.cpp b/src/futils.cpp index ddbbf0ac..cccb0ded 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -30,10 +30,14 @@ namespace fs = std::experimental::filesystem; // clang-format on #endif -#if defined(__APPLE__) && defined(EXV_HAVE_LIBPROC_H) +#if __has_include() #include #endif +#if __has_include() +#include // for stat() +#endif + #if defined(__FreeBSD__) #include #include @@ -45,10 +49,6 @@ namespace fs = std::experimental::filesystem; #include #endif -#ifdef EXV_HAVE_UNISTD_H -#include // for stat() -#endif - #ifndef _MAX_PATH #define _MAX_PATH 1024 #endif @@ -346,14 +346,12 @@ std::string getProcessPath() { } CloseHandle(processHandle); } -#elif defined(__APPLE__) -#ifdef EXV_HAVE_LIBPROC_H +#elif __has_include() const int pid = getpid(); char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; if (proc_pidpath(pid, pathbuf, sizeof(pathbuf)) > 0) { ret = pathbuf; } -#endif #elif defined(__FreeBSD__) unsigned int n; char buffer[PATH_MAX] = {}; diff --git a/src/version.cpp b/src/version.cpp index 0ccb7c12..b9c8bcc2 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -312,7 +312,7 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector& key int enable_video = 0; int use_curl = 0; -#ifdef EXV_HAVE_INTTYPES_H +#if __has_include() have_inttypes = 1; #endif @@ -324,21 +324,23 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector& key have_iconv = 1; #endif -#ifdef EXV_HAVE_LIBINTL_H +#if __has_include() have_libintl = 1; #endif -#ifdef EXV_HAVE_MEMORY_H +#if __has_include() have_memory = 1; #endif -#ifdef EXV_HAVE_STDBOOL_H +#if __has_include() have_stdbool = 1; #endif +#if __has_include() have_stdint = 1; +#endif -#ifdef EXV_HAVE_STDLIB_H +#if __has_include() have_stdlib = 1; #endif @@ -346,7 +348,7 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector& key have_strerror_r = 1; #endif -#ifdef EXV_HAVE_STRINGS_H +#if __has_include() have_strings = 1; #endif @@ -358,19 +360,19 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector& key have_munmap = 1; #endif -#ifdef EXV_HAVE_SYS_STAT_H +#if __has_include() have_sys_stat = 1; #endif -#ifdef EXV_HAVE_SYS_TYPES_H +#if __has_include() have_sys_types = 1; #endif -#ifdef EXV_HAVE_UNISTD_H +#if __has_include() have_unistd = 1; #endif -#ifdef EXV_HAVE_SYS_MMAN_H +#if __has_include() have_sys_mman = 1; #endif @@ -390,22 +392,6 @@ void Exiv2::dumpLibraryInfo(std::ostream& os, const std::vector& key adobe_xmpsdk = EXV_ADOBE_XMPSDK; #endif -#ifdef EXV_HAVE_BOOL - have_bool = 1; -#endif - -#ifdef EXV_HAVE_STRINGS - have_strings = 1; -#endif - -#ifdef EXV_SYS_TYPES - have_sys_types = 1; -#endif - -#ifdef EXV_HAVE_UNISTD - have_unistd = 1; -#endif - #ifdef EXV_ENABLE_BMFF enable_bmff = 1; #endif