Makes the code compile on Windows CE.

This commit is contained in:
zhanyong.wan
2009-03-11 23:37:56 +00:00
parent 93ad3551c0
commit 5b5d62f190
5 changed files with 50 additions and 6 deletions

View File

@@ -55,7 +55,9 @@ namespace {
using ::std::ostream;
#if GTEST_OS_WINDOWS
#ifdef _WIN32_WCE
#define snprintf _snprintf
#elif GTEST_OS_WINDOWS
#define snprintf _snprintf_s
#endif
@@ -157,9 +159,11 @@ static void PrintAsWideCharLiteralTo(wchar_t c, ostream* os) {
*os << "\\v";
break;
default:
// isprint() takes an int and requires it to be either EOF or in
// the range [0, 255]. We check that c is in this range before calling it.
if ((c & 0xFF) == c && isprint(c)) {
// Checks whether c is printable or not. Printable characters are in
// the range [0x20,0x7E].
// We test the value of c directly instead of calling isprint(), as
// isprint() is buggy on Windows mobile.
if (0x20 <= c && c <= 0x7E) {
*os << static_cast<char>(c);
} else {
// Buffer size enough for the maximum number of digits and \0.

View File

@@ -33,7 +33,18 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
int main(int argc, char **argv) {
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// causes a link error when _tmain is defined in a static library and UNICODE
// is enabled. For this reason instead of _tmain, main function is used on
// Windows. See the following link to track the current status of this bug:
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464 // NOLINT
#ifdef _WIN32_WCE
#include <tchar.h> // NOLINT
int _tmain(int argc, TCHAR** argv) {
#else
int main(int argc, char** argv) {
#endif // _WIN32_WCE
std::cout << "Running main() from gmock_main.cc\n";
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's