Only export Init_thrift_native function from the Ruby binary extension
diff --git a/lib/rb/ext/binary_protocol_accelerated.c b/lib/rb/ext/binary_protocol_accelerated.c
index c9ae4d2..3240fdf 100644
--- a/lib/rb/ext/binary_protocol_accelerated.c
+++ b/lib/rb/ext/binary_protocol_accelerated.c
@@ -43,7 +43,7 @@
 
 static void write_i16_direct(VALUE trans, int16_t value) {
   char data[2];
-  
+
   data[1] = value;
   data[0] = (value >> 8);
 
@@ -131,7 +131,7 @@
     write_byte_direct(trans, FIX2INT(type));
     write_i32_direct(trans, FIX2INT(seqid));
   }
-  
+
   return Qnil;
 }
 
@@ -139,7 +139,7 @@
   VALUE trans = GET_TRANSPORT(self);
   write_byte_direct(trans, FIX2INT(type));
   write_i16_direct(trans, FIX2INT(id));
-  
+
   return Qnil;
 }
 
@@ -153,7 +153,7 @@
   write_byte_direct(trans, FIX2INT(ktype));
   write_byte_direct(trans, FIX2INT(vtype));
   write_i32_direct(trans, FIX2INT(size));
-  
+
   return Qnil;
 }
 
@@ -161,7 +161,7 @@
   VALUE trans = GET_TRANSPORT(self);
   write_byte_direct(trans, FIX2INT(etype));
   write_i32_direct(trans, FIX2INT(size));
-  
+
   return Qnil;
 }
 
@@ -311,9 +311,9 @@
   VALUE strict_read = GET_STRICT_READ(self);
   VALUE name, seqid;
   int type;
-  
+
   int version = read_i32_direct(self);
-  
+
   if (version < 0) {
     if ((version & VERSION_MASK) != VERSION_1) {
       rb_exc_raise(get_protocol_exception(INT2FIX(BAD_VERSION), rb_str_new2("Missing version identifier")));
@@ -329,7 +329,7 @@
     type = read_byte_direct(self);
     seqid = rb_thrift_binary_proto_read_i32(self);
   }
-  
+
   return rb_ary_new3(3, name, INT2FIX(type), seqid);
 }
 
@@ -400,7 +400,7 @@
   return READ(self, size);
 }
 
-void Init_binary_protocol_accelerated() {
+void Init_binary_protocol_accelerated(void) {
   VALUE thrift_binary_protocol_class = rb_const_get(thrift_module, rb_intern("BinaryProtocol"));
 
   VERSION_1 = (int)rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_1")));
diff --git a/lib/rb/ext/compact_protocol.c b/lib/rb/ext/compact_protocol.c
index c98c09e..62c17e1 100644
--- a/lib/rb/ext/compact_protocol.c
+++ b/lib/rb/ext/compact_protocol.c
@@ -102,7 +102,7 @@
   int id = FIX2INT(id_value);
   int last_id = LAST_ID(self);
   VALUE transport = GET_TRANSPORT(self);
-  
+
   // if there's a type override, use that.
   int8_t type_to_write = RTEST(type_override) ? FIX2INT(type_override) : get_compact_type(type);
   // check if we can use delta encoding for the field id
@@ -206,7 +206,7 @@
   write_byte_direct(transport, (VERSION & VERSION_MASK) | ((FIX2INT(type) << TYPE_SHIFT_AMOUNT) & TYPE_MASK));
   write_varint32(transport, FIX2INT(seqid));
   rb_thrift_compact_proto_write_string(self, name);
-  
+
   return Qnil;
 }
 
@@ -441,7 +441,7 @@
     buf[len] = 0;
     rb_exc_raise(get_protocol_exception(INT2FIX(-1), rb_str_new2(buf)));
   }
-  
+
   int8_t version_and_type = read_byte_direct(self);
   int8_t version = version_and_type & VERSION_MASK;
   if (version != VERSION) {
@@ -450,7 +450,7 @@
     buf[len] = 0;
     rb_exc_raise(get_protocol_exception(INT2FIX(-1), rb_str_new2(buf)));
   }
-  
+
   int8_t type = (version_and_type >> TYPE_SHIFT_AMOUNT) & TYPE_BITS;
   int32_t seqid = (int32_t)read_varint64(self);
   VALUE messageName = rb_thrift_compact_proto_read_string(self);
@@ -467,7 +467,7 @@
 
     // mask off the 4 MSB of the type header. it could contain a field id delta.
     uint8_t modifier = ((type & 0xf0) >> 4);
-    
+
     if (modifier == 0) {
       // not a delta. look ahead for the zigzag varint field id.
       (void) LAST_ID(self);
@@ -565,7 +565,7 @@
   return READ(self, size);
 }
 
-static void Init_constants() {
+static void Init_constants(void) {
   thrift_compact_protocol_class = rb_const_get(thrift_module, rb_intern("CompactProtocol"));
   rb_global_variable(&thrift_compact_protocol_class);
 
@@ -582,7 +582,7 @@
   rbuf_ivar_id = rb_intern("@rbuf");
 }
 
-static void Init_rb_methods() {
+static void Init_rb_methods(void) {
   rb_define_method(thrift_compact_protocol_class, "native?", rb_thrift_compact_proto_native_qmark, 0);
 
   rb_define_method(thrift_compact_protocol_class, "write_message_begin", rb_thrift_compact_proto_write_message_begin, 3);
@@ -632,7 +632,7 @@
   rb_define_method(thrift_compact_protocol_class, "read_set_end",       rb_thrift_compact_proto_read_set_end, 0);
 }
 
-void Init_compact_protocol() {
+void Init_compact_protocol(void) {
   Init_constants();
   Init_rb_methods();
 }
diff --git a/lib/rb/ext/extconf.rb b/lib/rb/ext/extconf.rb
index b35f60b..91464cc 100644
--- a/lib/rb/ext/extconf.rb
+++ b/lib/rb/ext/extconf.rb
@@ -1,4 +1,4 @@
-# 
+#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements. See the NOTICE file
 # distributed with this work for additional information
@@ -6,27 +6,28 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License. You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 # KIND, either express or implied. See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# 
+#
 
 if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
   File.open('Makefile', 'w'){|f| f.puts "all:\n\ninstall:\n" }
 else
   require 'mkmf'
-  require 'rbconfig'
 
-  $ARCH_FLAGS = RbConfig::CONFIG['CFLAGS'].scan( /(-arch )(\S+)/ ).map{|x,y| x + y + ' ' }.join('')
+  append_cflags(["-fsigned-char", "-g", "-O2", "-Wall", "-Werror", "-Werror=old-style-definition"])
 
-
-  $CFLAGS = "-fsigned-char -g -O2 -Wall -Werror " + $ARCH_FLAGS
+  # Makes all symbols private by default to avoid unintended conflict
+  # with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
+  # selectively, or entirely remove this flag.
+  append_cflags("-fvisibility=hidden")
 
   have_func("strlcpy", "string.h")
 
diff --git a/lib/rb/ext/memory_buffer.c b/lib/rb/ext/memory_buffer.c
index 96604af..7c3675a 100644
--- a/lib/rb/ext/memory_buffer.c
+++ b/lib/rb/ext/memory_buffer.c
@@ -45,13 +45,13 @@
 
 VALUE rb_thrift_memory_buffer_read(VALUE self, VALUE length_value) {
   int length = FIX2INT(length_value);
-  
+
   VALUE index_value = rb_ivar_get(self, index_ivar_id);
   int index = FIX2INT(index_value);
-  
+
   VALUE buf = GET_BUF(self);
   VALUE data = rb_funcall(buf, slice_method_id, 2, index_value, length_value);
-  
+
   index += length;
   if (index > RSTRING_LEN(buf)) {
     index = (int)RSTRING_LEN(buf);
@@ -118,17 +118,17 @@
   return INT2FIX(i);
 }
 
-void Init_memory_buffer() {
+void Init_memory_buffer(void) {
   VALUE thrift_memory_buffer_class = rb_const_get(thrift_module, rb_intern("MemoryBufferTransport"));
   rb_define_method(thrift_memory_buffer_class, "write", rb_thrift_memory_buffer_write, 1);
   rb_define_method(thrift_memory_buffer_class, "read", rb_thrift_memory_buffer_read, 1);
   rb_define_method(thrift_memory_buffer_class, "read_byte", rb_thrift_memory_buffer_read_byte, 0);
   rb_define_method(thrift_memory_buffer_class, "read_into_buffer", rb_thrift_memory_buffer_read_into_buffer, 2);
-  
+
   buf_ivar_id = rb_intern("@buf");
   index_ivar_id = rb_intern("@index");
-  
+
   slice_method_id = rb_intern("slice");
-  
+
   GARBAGE_BUFFER_SIZE = FIX2INT(rb_const_get(thrift_memory_buffer_class, rb_intern("GARBAGE_BUFFER_SIZE")));
 }
diff --git a/lib/rb/ext/struct.c b/lib/rb/ext/struct.c
index e8255a9..ad33a81 100644
--- a/lib/rb/ext/struct.c
+++ b/lib/rb/ext/struct.c
@@ -691,7 +691,7 @@
   return Qnil;
 }
 
-void Init_struct() {
+void Init_struct(void) {
   VALUE struct_module = rb_const_get(thrift_module, rb_intern("Struct"));
 
   rb_define_method(struct_module, "write", rb_thrift_struct_write, 1);
diff --git a/lib/rb/ext/thrift_native.c b/lib/rb/ext/thrift_native.c
index d535454..7c99f5e 100644
--- a/lib/rb/ext/thrift_native.c
+++ b/lib/rb/ext/thrift_native.c
@@ -109,7 +109,7 @@
 VALUE binary_sym;
 VALUE protocol_exception_class;
 
-void Init_thrift_native() {
+RUBY_FUNC_EXPORTED void Init_thrift_native(void) {
   // cached classes
   thrift_module = rb_const_get(rb_cObject, rb_intern("Thrift"));
   rb_global_variable(&thrift_module);
@@ -168,7 +168,7 @@
   read_binary_method_id = rb_intern("read_binary");
   read_double_method_id = rb_intern("read_double");
   read_map_begin_method_id = rb_intern("read_map_begin");
-  read_map_end_method_id = rb_intern("read_map_end");  
+  read_map_end_method_id = rb_intern("read_map_end");
   read_list_begin_method_id = rb_intern("read_list_begin");
   read_list_end_method_id = rb_intern("read_list_end");
   read_set_begin_method_id = rb_intern("read_set_begin");
@@ -192,7 +192,7 @@
   fields_const_id = rb_intern("FIELDS");
   transport_ivar_id = rb_intern("@trans");
   strict_read_ivar_id = rb_intern("@strict_read");
-  strict_write_ivar_id = rb_intern("@strict_write");  
+  strict_write_ivar_id = rb_intern("@strict_write");
 
   // cached symbols
   type_sym = ID2SYM(rb_intern("type"));