mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 05:08:45 +08:00
Fix fcloseall not defined on some platform
This commit is contained in:
@@ -50,6 +50,13 @@ check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
|
||||
if (HAVE_STRERROR_R)
|
||||
test_strerror_r(HAVE_GNU_STRERROR_R)
|
||||
endif()
|
||||
if (NOT WIN32)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||
check_symbol_exists(fcloseall "stdio.h" HAVE_FCLOSEALL)
|
||||
if (HAVE_FCLOSEALL)
|
||||
add_compile_definitions(_GNU_SOURCE)
|
||||
endif()
|
||||
endif()
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/utils_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/utils_config.h")
|
||||
|
||||
if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
|
||||
|
||||
@@ -539,7 +539,9 @@ std::string fileop::filename(std::string path) {
|
||||
int fileop::fcloseall() {
|
||||
#if _WIN32
|
||||
return ::_fcloseall();
|
||||
#else
|
||||
#elif HAVE_FCLOSEALL
|
||||
return ::fcloseall();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
1
fileop.h
1
fileop.h
@@ -171,6 +171,7 @@ namespace fileop {
|
||||
std::string filename(std::string path);
|
||||
/**
|
||||
* @brief Close all open streams
|
||||
* If no function is called, will return 0.
|
||||
* @return 0(>=0) succeed. EOF error happened.
|
||||
*/
|
||||
int fcloseall();
|
||||
|
||||
@@ -16,3 +16,4 @@
|
||||
#cmakedefine HAVE_STRCASECMP @HAVE_STRCASECMP@
|
||||
#cmakedefine HAVE__STRNICMP @HAVE__STRNICMP@
|
||||
#cmakedefine HAVE_STRNCASECMP @HAVE_STRNCASECMP@
|
||||
#cmakedefine HAVE_FCLOSEALL @HAVE_FCLOSEALL@
|
||||
|
||||
Reference in New Issue
Block a user