From e120fc58906cd7ca6492ba634bb7e082167bd5bf Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Thu, 26 Mar 2009 21:11:22 +0000 Subject: Works around a VC bug by avoiding defining a function named strdup(). --- include/gtest/internal/gtest-port.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/gtest') diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index cfb214f5..d4ffbb41 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -736,13 +736,18 @@ namespace posix { typedef struct _stat stat_struct; inline int chdir(const char* dir) { return ::_chdir(dir); } +// We cannot write ::_fileno() as MSVC defines it as a macro. inline int fileno(FILE* file) { return _fileno(file); } inline int isatty(int fd) { return ::_isatty(fd); } -inline int stat(const char* path, stat_struct* buf) { return ::_stat(path, buf); } +inline int stat(const char* path, stat_struct* buf) { + return ::_stat(path, buf); +} inline int strcasecmp(const char* s1, const char* s2) { return ::_stricmp(s1, s2); } -inline const char* strdup(const char* src) { return ::_strdup(src); } +// We cannot define the function as strdup(const char* src), since +// MSVC defines strdup as a macro. +inline char* StrDup(const char* src) { return ::_strdup(src); } inline int rmdir(const char* dir) { return ::_rmdir(dir); } inline bool IsDir(const stat_struct& st) { return (_S_IFDIR & st.st_mode) != 0; @@ -757,7 +762,7 @@ using ::fileno; using ::isatty; using ::stat; using ::strcasecmp; -using ::strdup; +inline char* StrDup(const char* src) { return ::strdup(src); } using ::rmdir; inline bool IsDir(const stat_struct& st) { return S_ISDIR(st.st_mode); } -- cgit v1.2.3