diff --git a/examples/test_ffi_struct.rb b/examples/test_ffi_struct.rb
index <HASH>..<HASH> 100644
--- a/examples/test_ffi_struct.rb
+++ b/examples/test_ffi_struct.rb
@@ -14,10 +14,22 @@ bar[:p][:a] = 20
 foo = Foo.new(bar.to_ptr)
 puts foo[:a]
 
+class MyFFIStruct < FFI::Struct
+  class << self
+    def find_type(type, mod = nil)
+      if type.kind_of?(Class) && type.const_defined?(:Struct)
+	FFI::Type::Struct.new(type.const_get(:Struct))
+      else
+	super type, mod
+      end
+    end
+  end
+end
+
 class Foo2
   extend Forwardable
   def_delegators :@struct, :[], :to_ptr
-  class Struct < FFI::Struct
+  class Struct < MyFFIStruct
     layout :a, :int, :b, :int
   end
   def initialize(ptr=nil)
@@ -26,8 +38,8 @@ class Foo2
 end
 
 class Bar2 < Foo2
-  class Struct < FFI::Struct
-    layout :p, Foo2::Struct, :c, :int
+  class Struct < MyFFIStruct
+    layout :p, Foo2, :c, :int
   end
   def initialize(ptr=nil)
     @struct = Struct.new(ptr)
Use derived class of FFI::Struct that overrides self.find_type.