Added a preprocessor flag SFNTLY_NO_EXCEPTION to disable exception handling.  Fixed the code to make GCC -Wall -Werror flags happy.

git-svn-id: http://sfntly.googlecode.com/svn/trunk/cpp/src@3 672e30a5-4c29-85ac-ac6d-611c735e0a51
diff --git a/sfntly/cmap_table.cc b/sfntly/cmap_table.cc
index 11b2b50..79b083a 100644
--- a/sfntly/cmap_table.cc
+++ b/sfntly/cmap_table.cc
@@ -445,7 +445,7 @@
  * CMapTable::Iterator class
  ******************************************************************************/
 CMapTable::CMapIterator::CMapIterator(CMapTable* table, CMapFilter* filter)
-    : table_index_(0), table_(table), filter_(filter) {}
+    : table_index_(0), filter_(filter), table_(table) {}
 
 bool CMapTable::CMapIterator::hasNext() {
   if (!filter_) {
diff --git a/sfntly/data/byte_array.cc b/sfntly/data/byte_array.cc
index 3511bfe..d5af22e 100644
--- a/sfntly/data/byte_array.cc
+++ b/sfntly/data/byte_array.cc
@@ -121,7 +121,11 @@
   while ((bytes_read = get(index + src_offset, &b, 0, buffer_length)) > 0) {
     int bytes_written = array->put(index + dst_offset, &b, 0, bytes_read);
     if (bytes_written != bytes_read) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return 0;
+#else
       throw IOException("Error writing bytes.");
+#endif
     }
     index += bytes_read;
     remaining_length -= bytes_read;
@@ -155,7 +159,11 @@
   while ((bytes_read =
           is->read(&b, 0, buffer_length)) > 0) {
     if (put(index, &b, 0, bytes_read) != bytes_read) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return 0;
+#else
       throw IOException("Error writing bytes.");
+#endif
     }
     index += bytes_read;
     length -= bytes_read;
@@ -172,7 +180,11 @@
   while ((bytes_read =
           is->read(&b, 0, buffer_length)) > 0) {
     if (put(index, &b, 0, bytes_read) != bytes_read) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return 0;
+#else
       throw IOException("Error writing bytes.");
+#endif
     }
     index += bytes_read;
   }
diff --git a/sfntly/data/font_input_stream.cc b/sfntly/data/font_input_stream.cc
index 8b1d798..97c5860 100644
--- a/sfntly/data/font_input_stream.cc
+++ b/sfntly/data/font_input_stream.cc
@@ -21,11 +21,11 @@
 namespace sfntly {
 
 FontInputStream::FontInputStream(InputStream* is)
-    : position_(0), length_(0), bounded_(false), stream_(is) {
+    : stream_(is), position_(0), length_(0), bounded_(false) {
 }
 
 FontInputStream::FontInputStream(InputStream* is, size_t length)
-    : position_(0), length_(length), bounded_(false), stream_(is) {
+    : stream_(is), position_(0), length_(length), bounded_(false) {
 }
 
 FontInputStream::~FontInputStream() {
diff --git a/sfntly/data/font_output_stream.cc b/sfntly/data/font_output_stream.cc
index d5eaa82..86a153c 100644
--- a/sfntly/data/font_output_stream.cc
+++ b/sfntly/data/font_output_stream.cc
@@ -22,7 +22,7 @@
 namespace sfntly {
 
 FontOutputStream::FontOutputStream(OutputStream* os)
-    : position_(0), stream_(os) {
+    : stream_(os), position_(0) {
 }
 
 FontOutputStream::~FontOutputStream() {
diff --git a/sfntly/data/memory_byte_array.cc b/sfntly/data/memory_byte_array.cc
index 1e85ebd..528979a 100644
--- a/sfntly/data/memory_byte_array.cc
+++ b/sfntly/data/memory_byte_array.cc
@@ -22,7 +22,7 @@
 
 // Note: this constructor can fail under low-memory situation
 MemoryByteArray::MemoryByteArray(int32_t length)
-    : ByteArray(0, length), allocated_(true), b_(NULL) {
+    : ByteArray(0, length), b_(NULL), allocated_(true) {
 }
 
 MemoryByteArray::MemoryByteArray(byte_t* b, int32_t buffer_length)
diff --git a/sfntly/data/readable_font_data.cc b/sfntly/data/readable_font_data.cc
index 3073b03..fa7279e 100644
--- a/sfntly/data/readable_font_data.cc
+++ b/sfntly/data/readable_font_data.cc
@@ -23,16 +23,16 @@
 ReadableFontData::~ReadableFontData() {}
 
 ReadableFontData::ReadableFontData(ByteArray* array)
-    : FontData(array), checksum_(0), checksum_set_(false) {
+    : FontData(array), checksum_set_(false), checksum_(0) {
 }
 
 ReadableFontData::ReadableFontData(ReadableFontData* data, int32_t offset)
-    : FontData(data, offset), checksum_(0), checksum_set_(false) {
+    : FontData(data, offset), checksum_set_(false), checksum_(0) {
 }
 
 ReadableFontData::ReadableFontData(ReadableFontData* data, int32_t offset,
                                    int32_t length)
-    : FontData(data, offset, length), checksum_(0), checksum_set_(false) {
+    : FontData(data, offset, length), checksum_set_(false), checksum_(0) {
 }
 
 int64_t ReadableFontData::checksum() {
@@ -133,9 +133,11 @@
 
 int32_t ReadableFontData::readULongAsInt(int32_t index) {
   int64_t ulong = readULong(index);
+#if !defined (SFNTLY_NO_EXCEPTION)
   if ((ulong & 0x80000000) == 0x80000000) {
     throw ArithmeticException("Long value too large to fit into an integer.");
   }
+#endif
   return ((int32_t)ulong) & ~0x80000000;
 }
 
diff --git a/sfntly/font.cc b/sfntly/font.cc
index 1ef222a..46dc48c 100644
--- a/sfntly/font.cc
+++ b/sfntly/font.cc
@@ -118,8 +118,8 @@
 Font::~Font() {}
 
 Font::Font(FontFactory* factory, int32_t sfnt_version, ByteVector* digest,
-           TableMap* tables) :
-    sfnt_version_(sfnt_version), factory_(factory) {
+           TableMap* tables)
+    : factory_(factory), sfnt_version_(sfnt_version) {
   // non-trivial assignments that makes debugging hard if placed in
   // initialization list
   digest_ = *digest;
@@ -223,7 +223,11 @@
                                  record != end_of_headers; ++record) {
     TablePtr target_table = table((*record)->tag());
     if (target_table == NULL) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return;
+#else
       throw IOException("Table out of sync with font header.");
+#endif
     }
     int32_t table_size = target_table->serialize(fos);
     int32_t filler_size = ((table_size + 3) & ~3) - table_size;
@@ -462,19 +466,27 @@
                                  builder != builder_end; ++builder) {
     TablePtr table;
     if (builder->second->readyToBuild()) {
+#if !defined (SFNTLY_NO_EXCEPTION)
       try {
+#endif
         table.attach(down_cast<Table*>(builder->second->build()));
+#if !defined (SFNTLY_NO_EXCEPTION)
       } catch(IOException& e) {
         std::string builder_string = "Unable to build table - ";
         builder_string += typeid(builder->second).name();
         builder_string += e.what();
         throw RuntimeException(builder_string.c_str());
       }
+#endif
     }
     if (table == NULL) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return;
+#else
       std::string builder_string = "Unable to build table - ";
       builder_string += typeid(builder->second).name();
       throw RuntimeException(builder_string.c_str());
+#endif
     }
     table_map->insert(TableMapEntry(table->header()->tag(), table));
   }
diff --git a/sfntly/glyph_table.cc b/sfntly/glyph_table.cc
index 72f6945..4cd6436 100644
--- a/sfntly/glyph_table.cc
+++ b/sfntly/glyph_table.cc
@@ -109,8 +109,12 @@
                                      const IntegerList& loca) {
   if (data != NULL) {
     if (loca_.empty()) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return;
+#else
       throw IllegalStateException(
           "Loca values not set - unable to parse glyph data.");
+#endif
     }
     int32_t loca_value;
     int32_t last_loca_value = loca[0];
@@ -513,8 +517,8 @@
  * GlyphTable::CompositeGlyph and its builder
  ******************************************************************************/
 GlyphTable::CompositeGlyph::CompositeGlyph(ReadableFontData* data)
-    : instruction_size_(0), instructions_offset_(0),
-      GlyphTable::Glyph(data, GlyphType::kComposite) {
+    : GlyphTable::Glyph(data, GlyphType::kComposite),
+      instruction_size_(0), instructions_offset_(0) {
   parseData();
 }
 
diff --git a/sfntly/horizontal_metrics_table.cc b/sfntly/horizontal_metrics_table.cc
index 4ed2d43..d6beab1 100644
--- a/sfntly/horizontal_metrics_table.cc
+++ b/sfntly/horizontal_metrics_table.cc
@@ -54,7 +54,11 @@
 
 int32_t HorizontalMetricsTable::hMetricAdvanceWidth(int32_t entry) {
   if (entry > num_hmetrics_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException();
+#endif
   }
   int32_t offset = Offset::kHMetricsStart + (entry * Offset::kHMetricsSize) +
                    Offset::kHMetricsAdvanceWidth;
@@ -63,7 +67,11 @@
 
 int32_t HorizontalMetricsTable::hMetricLSB(int32_t entry) {
   if (entry > num_hmetrics_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException();
+#endif
   }
   int32_t offset = Offset::kHMetricsStart + (entry * Offset::kHMetricsSize) +
                    Offset::kHMetricsLeftSideBearing;
@@ -72,7 +80,11 @@
 
 int32_t HorizontalMetricsTable::lsbTableEntry(int32_t entry) {
   if (entry > num_hmetrics_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException();
+#endif
   }
   int32_t offset = Offset::kHMetricsStart + (entry * Offset::kHMetricsSize) +
                    Offset::kLeftSideBearingSize;
diff --git a/sfntly/loca_table.cc b/sfntly/loca_table.cc
index 5bb5dd4..1cd1d92 100644
--- a/sfntly/loca_table.cc
+++ b/sfntly/loca_table.cc
@@ -36,14 +36,22 @@
 
 int32_t LocaTable::glyphOffset(int32_t glyph_id) {
   if (glyph_id < 0 || glyph_id >= num_glyphs_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException("Glyph ID is out of bounds.");
+#endif
   }
   return loca(glyph_id);
 }
 
 int32_t LocaTable::glyphLength(int32_t glyph_id) {
   if (glyph_id < 0 || glyph_id >= num_glyphs_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException("Glyph ID is out of bounds.");
+#endif
   }
   return loca(glyph_id + 1) - loca(glyph_id);
 }
@@ -54,7 +62,11 @@
 
 int32_t LocaTable::loca(int32_t index) {
   if (index > num_glyphs_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException();
+#endif
   }
   if (version_ == IndexToLocFormat::kShortOffset) {
     return 2 * data_->readShort(index * DataSize::kUSHORT);
@@ -102,7 +114,11 @@
 void LocaTable::Builder::initialize(ReadableFontData* data) {
   if (data) {
     if (numGlyphs() < 0) {
+#if defined (SFNTLY_NO_EXCEPTION)
+      return;
+#else
       throw IllegalStateException("numglyphs not set on LocaTable Builder.");
+#endif
     }
     LocaTablePtr table =
         new LocaTable(header(), data, format_version_, num_glyphs_);
@@ -140,14 +156,22 @@
 
 int32_t LocaTable::Builder::glyphOffset(int32_t glyph_id) {
   if (glyph_id < 0 || glyph_id > (num_glyphs_ + 1)) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException("Glyph ID is out of bounds.");
+#endif
   }
   return loca(glyph_id);
 }
 
 int32_t LocaTable::Builder::glyphLength(int32_t glyph_id) {
   if (glyph_id < 0 || glyph_id > (num_glyphs_ + 1)) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IndexOutOfBoundException("Glyph ID is out of bounds.");
+#endif
   }
   return loca(glyph_id + 1) - loca(glyph_id);
 }
diff --git a/sfntly/name_table.cc b/sfntly/name_table.cc
index e303d6d..b344bfa 100644
--- a/sfntly/name_table.cc
+++ b/sfntly/name_table.cc
@@ -549,7 +549,7 @@
  ******************************************************************************/
 NameTable::NameEntryIterator::NameEntryIterator(NameTable* table,
                                                 NameEntryFilter* filter) :
-    table_(table), filter_(filter), name_index_(0) {
+    table_(table), name_index_(0), filter_(filter) {
 }
 
 bool NameTable::NameEntryIterator::hasNext() {
diff --git a/sfntly/port/exception_type.h b/sfntly/port/exception_type.h
index 56a93ff..2ba199a 100644
--- a/sfntly/port/exception_type.h
+++ b/sfntly/port/exception_type.h
@@ -19,6 +19,8 @@
 #ifndef TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_PORT_EXCEPTION_TYPE_H_
 #define TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_PORT_EXCEPTION_TYPE_H_
 
+#if !defined (SFNTLY_NO_EXCEPTION)
+
 #include <exception>
 #include <string>
 
@@ -104,4 +106,6 @@
 
 }  // namespace sfntly
 
+#endif  // #if !defined (SFNTLY_NO_EXCEPTION)
+
 #endif  // TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_PORT_EXCEPTION_TYPE_H_
diff --git a/sfntly/port/file_input_stream.cc b/sfntly/port/file_input_stream.cc
index 7505ab7..dcb37f7 100644
--- a/sfntly/port/file_input_stream.cc
+++ b/sfntly/port/file_input_stream.cc
@@ -23,7 +23,7 @@
 
 namespace sfntly {
 
-FileInputStream::FileInputStream() : file_(NULL), length_(0), position_(0) {
+FileInputStream::FileInputStream() : file_(NULL), position_(0), length_(0) {
 }
 
 FileInputStream::~FileInputStream() {
@@ -73,10 +73,18 @@
 
 int32_t FileInputStream::read() {
   if (!file_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IOException("no opened file");
+#endif
   }
   if (feof(file_)) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IOException("eof reached");
+#endif
   }
   byte_t value;
   fread(&value, 1, 1, file_);
@@ -92,10 +100,18 @@
   assert(b);
   assert(b->size() >= (size_t)(offset + length));
   if (!file_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IOException("no opened file");
+#endif
   }
   if (feof(file_)) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IOException("eof reached");
+#endif
   }
   size_t read_count = std::min<size_t>(length_ - position_, length);
   int32_t actual_read = fread(&((*b)[offset]), 1, read_count, file_);
@@ -109,7 +125,11 @@
 
 int64_t FileInputStream::skip(int64_t n) {
   if (!file_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return 0;
+#else
     throw IOException("no opened file");
+#endif
   }
   if (n < 0) {
     return 0;
@@ -128,7 +148,11 @@
   assert(b);
   assert(b->size() >= size_t(offset + length));
   if (!file_) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return;
+#else
     throw IOException("no opened file");
+#endif
   }
   size_t unread_count = std::min<size_t>(position_, length);
   fseek(file_, position_ - unread_count, SEEK_SET);
diff --git a/sfntly/port/type.h b/sfntly/port/type.h
index ab55b97..25b697e 100644
--- a/sfntly/port/type.h
+++ b/sfntly/port/type.h
@@ -78,7 +78,7 @@
 }
 
 #if !defined(WIN32)
-  #define UNREFERENCED_PARAMETER(p)
+  #define UNREFERENCED_PARAMETER(p) do { (void)p; } while (0)
 #endif
 
 #endif  // TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_PORT_TYPE_H_
diff --git a/sfntly/table.cc b/sfntly/table.cc
index 1215f50..856f32e 100644
--- a/sfntly/table.cc
+++ b/sfntly/table.cc
@@ -74,19 +74,19 @@
  * Table::Header class
  ******************************************************************************/
 Table::Header::Header(int32_t tag)
-    : tag_(tag), checksum_(0), checksum_valid_(false), offset_(0), length_(0),
-      offset_valid_(false) {
+    : tag_(tag), offset_(0), length_(0), offset_valid_(false), checksum_(0),
+      checksum_valid_(false) {
 }
 
 Table::Header::Header(int32_t tag, int32_t length)
-    : tag_(tag), checksum_(0), checksum_valid_(false), offset_(0),
-      length_(length), offset_valid_(false) {
+    : tag_(tag), offset_(0), length_(length), offset_valid_(false),
+      checksum_(0), checksum_valid_(false) {
 }
 
 Table::Header::Header(int32_t tag, int64_t checksum, int32_t offset,
                       int32_t length)
-    : tag_(tag), checksum_(checksum), checksum_valid_(true), offset_(offset),
-      length_(length), offset_valid_(true) {
+    : tag_(tag), offset_(offset), length_(length), offset_valid_(true),
+      checksum_(checksum), checksum_valid_(true) {
 }
 
 Table::Header::~Header() {}
diff --git a/sfntly/tools/subsetter/glyph_table_subsetter.cc b/sfntly/tools/subsetter/glyph_table_subsetter.cc
index 93a8852..04d0c48 100644
--- a/sfntly/tools/subsetter/glyph_table_subsetter.cc
+++ b/sfntly/tools/subsetter/glyph_table_subsetter.cc
@@ -44,7 +44,11 @@
   GlyphTablePtr glyph_table = down_cast<GlyphTable*>(font->table(Tag::glyf));
   LocaTablePtr loca_table = down_cast<LocaTable*>(font->table(Tag::loca));
   if (glyph_table == NULL || loca_table == NULL) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return false;
+#else
     throw RuntimeException("Font to subset is not valid.");
+#endif
   }
 
   GlyphTableBuilderPtr glyph_table_builder;
@@ -54,7 +58,11 @@
   loca_table_builder.attach(down_cast<LocaTable::Builder*>(
        font_builder->newTableBuilder(Tag::loca)));
   if (glyph_table_builder == NULL || loca_table_builder == NULL) {
+#if defined (SFNTLY_NO_EXCEPTION)
+    return false;
+#else
     throw RuntimeException("Builder for subset is not valid.");
+#endif
   }
   GlyphTable::GlyphBuilderList* glyph_builders =
       glyph_table_builder->glyphBuilders();
diff --git a/test/byte_array_test.cc b/test/byte_array_test.cc
index d2c865f..7c6efa9 100644
--- a/test/byte_array_test.cc
+++ b/test/byte_array_test.cc
@@ -112,10 +112,10 @@
 }  // namespace byte_array_test
 
 bool testMemoryByteArray() {
-  for (int32_t i = 0;
+  for (size_t i = 0;
        i < sizeof(byte_array_test::BYTE_ARRAY_SIZES) / sizeof(int32_t); ++i) {
     int32_t size = byte_array_test::BYTE_ARRAY_SIZES[i];
-    fprintf(stderr, "fixed mem: iteration %d, size %d\n", i, size);
+    fprintf(stderr, "fixed mem: iteration %ld, size %d\n", i, size);
     ByteArrayPtr ba = new MemoryByteArray(size);
     byte_array_test::fillTestByteArray(ba, size);
     EXPECT_TRUE(byte_array_test::byteArrayTester(ba));
@@ -124,10 +124,10 @@
 }
 
 bool testGrowableMemoryByteArray() {
-  for (int32_t i = 0;
+  for (size_t i = 0;
        i < sizeof(byte_array_test::BYTE_ARRAY_SIZES) / sizeof(int32_t); ++i) {
     int32_t size = byte_array_test::BYTE_ARRAY_SIZES[i];
-    fprintf(stderr, "growable mem: iteration %d, size %d\n", i, size);
+    fprintf(stderr, "growable mem: iteration %ld, size %d\n", i, size);
     ByteArrayPtr ba = new GrowableMemoryByteArray();
     byte_array_test::fillTestByteArray(ba, size);
     EXPECT_TRUE(byte_array_test::byteArrayTester(ba));
diff --git a/test/font_data_test.cc b/test/font_data_test.cc
index 1e81626..ad30522 100644
--- a/test/font_data_test.cc
+++ b/test/font_data_test.cc
@@ -186,7 +186,7 @@
 }
 
 bool testReadableFontData() {
-  for (int32_t i = 0; i < sizeof(BYTE_ARRAY_SIZES) / sizeof(int32_t); ++i) {
+  for (size_t i = 0; i < sizeof(BYTE_ARRAY_SIZES) / sizeof(int32_t); ++i) {
     int32_t size = BYTE_ARRAY_SIZES[i];
     ByteArrayPtr ba = new MemoryByteArray(size);
     fillTestByteArray(ba, size);
@@ -197,7 +197,7 @@
 }
 
 bool testWritableFontData() {
-  for (int32_t i = 0; i < sizeof(BYTE_ARRAY_SIZES) / sizeof(int32_t); ++i) {
+  for (size_t i = 0; i < sizeof(BYTE_ARRAY_SIZES) / sizeof(int32_t); ++i) {
     int32_t size = BYTE_ARRAY_SIZES[i];
     ByteArrayPtr ba = new MemoryByteArray(size);
     fillTestByteArray(ba, size);
diff --git a/test/smart_pointer_test.cc b/test/smart_pointer_test.cc
index 8bc9f99..a35e289 100644
--- a/test/smart_pointer_test.cc
+++ b/test/smart_pointer_test.cc
@@ -33,44 +33,44 @@
   {
     Ptr<Foo> p1;
     p1 = new Foo();
-    EXPECT_EQ(1, p1->ref_count_);
-    EXPECT_EQ(1, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(1), p1->ref_count_);
+    EXPECT_EQ(size_t(1), RefCounted<Foo>::object_counter_);
 
     Ptr<Foo> p2;
     p2 = p1;
-    EXPECT_EQ(2, p1->ref_count_);
-    EXPECT_EQ(2, p2->ref_count_);
-    EXPECT_EQ(1, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(2), p1->ref_count_);
+    EXPECT_EQ(size_t(2), p2->ref_count_);
+    EXPECT_EQ(size_t(1), RefCounted<Foo>::object_counter_);
 
     Ptr<Foo> p3;
     p3 = p1;
-    EXPECT_EQ(3, p1->ref_count_);
-    EXPECT_EQ(3, p2->ref_count_);
-    EXPECT_EQ(3, p3->ref_count_);
-    EXPECT_EQ(1, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(3), p1->ref_count_);
+    EXPECT_EQ(size_t(3), p2->ref_count_);
+    EXPECT_EQ(size_t(3), p3->ref_count_);
+    EXPECT_EQ(size_t(1), RefCounted<Foo>::object_counter_);
 
     p2 = new Foo();
-    EXPECT_EQ(2, p1->ref_count_);
-    EXPECT_EQ(1, p2->ref_count_);
-    EXPECT_EQ(2, p3->ref_count_);
-    EXPECT_EQ(2, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(2), p1->ref_count_);
+    EXPECT_EQ(size_t(1), p2->ref_count_);
+    EXPECT_EQ(size_t(2), p3->ref_count_);
+    EXPECT_EQ(size_t(2), RefCounted<Foo>::object_counter_);
 
     p3.release();
-    EXPECT_EQ(1, p1->ref_count_);
+    EXPECT_EQ(size_t(1), p1->ref_count_);
     EXPECT_EQ(NULL, p3.p_);
-    EXPECT_EQ(2, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(2), RefCounted<Foo>::object_counter_);
 
     p2 = NULL;
-    EXPECT_EQ(1, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(1), RefCounted<Foo>::object_counter_);
 
     p1 = p1;
-    EXPECT_EQ(1, p1->ref_count_);
-    EXPECT_EQ(1, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(1), p1->ref_count_);
+    EXPECT_EQ(size_t(1), RefCounted<Foo>::object_counter_);
 
     p1 = &(*p1);
-    EXPECT_EQ(1, p1->ref_count_);
-    EXPECT_EQ(1, RefCounted<Foo>::object_counter_);
+    EXPECT_EQ(size_t(1), p1->ref_count_);
+    EXPECT_EQ(size_t(1), RefCounted<Foo>::object_counter_);
   }
-  EXPECT_EQ(0, RefCounted<Foo>::object_counter_);
+  EXPECT_EQ(size_t(0), RefCounted<Foo>::object_counter_);
   return true;
 }