From b6082e5088308596fc9dc98b35019519363979b5 Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Tue, 19 Dec 2023 19:08:48 +0100 Subject: [PATCH] fix: remove redundant POSIX function aliases (#990) The preprocessor defines interfere with method declarations, e.g., in std::basic_filebuf, resulting in following error: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.37.32822\include\fstream(376,26): error C2039: '_close': is not a member of 'std::basic_filebuf>' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.37.32822\include\iosfwd(244,35): message : see declaration of 'std::basic_filebuf>' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.37.32822\include\fstream(375,10): message : while compiling class template member function 'void std::basic_ofstream>::_close(void)' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj] D:\a\glog\glog\src\logging_unittest.cc(788,12): message : see the first reference to 'std::basic_ofstream>::_close' in 'TestBasenameAppendWhenNoTimestamp' [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj] D:\a\glog\glog\src\logging_unittest.cc(786,12): message : see reference to class template instantiation 'std::basic_ofstream>' being compiled [D:\a\glog\glog\build_Debug\logging_unittest.vcxproj] --- src/windows/port.h | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/windows/port.h b/src/windows/port.h index eecc46f..bedc2e8 100755 --- a/src/windows/port.h +++ b/src/windows/port.h @@ -49,15 +49,16 @@ #define WIN32_LEAN_AND_MEAN /* We always want minimal includes */ #endif +#include /* for _getcwd() */ +#include /* because we so often use open/close/etc */ +#include /* for _getpid() */ #include -#include /* for gethostname */ -#include /* because we so often use open/close/etc */ -#include /* for _getcwd() */ -#include /* for _getpid() */ -#include /* template_dictionary.cc uses va_copy */ -#include /* read in vsnprintf decl. before redifining it */ -#include /* for _strnicmp(), strerror_s() */ -#include /* for localtime_s() */ +#include /* for gethostname */ + +#include /* template_dictionary.cc uses va_copy */ +#include /* read in vsnprintf decl. before redefining it */ +#include /* for _strnicmp(), strerror_s() */ +#include /* for localtime_s() */ /* Note: the C++ #includes are all together at the bottom. This file is * used by both C and C++ code, so we put all the C++ together. */ @@ -80,13 +81,6 @@ /* file I/O */ #define PATH_MAX 1024 -#define access _access -#define getcwd _getcwd -#define open _open -#define read _read -#define write(fd, p, n) _write(fd, p, n) -#define lseek _lseek -#define close _close #define popen _popen #define pclose _pclose #define R_OK 04 /* read-only (for access()) */