From f0f998ccf33af7e63c0e509d2f56a2ffdfc98a29 Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sun, 18 Nov 2012 11:10:18 +0100 Subject: [PATCH] generator: Fix compilation warning in some generated interface adapters Don't generate a static field if it's not going to be used. This fixes a compilation warning on the generated code for interfaces that don't have virtual methods. --- generator/InterfaceGen.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index 8f979f7b2..4cec6aa7b 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -103,8 +103,10 @@ namespace GtkSharp.Generation { void GenerateInitialize (StreamWriter sw) { - sw.WriteLine ("\t\tstatic int class_offset = 2 * IntPtr.Size;"); // Class size of GTypeInterface struct - sw.WriteLine (); + if (interface_vms.Count > 0) { + sw.WriteLine ("\t\tstatic int class_offset = 2 * IntPtr.Size;"); // Class size of GTypeInterface struct + sw.WriteLine (); + } sw.WriteLine ("\t\tstatic void Initialize (IntPtr ptr, IntPtr data)"); sw.WriteLine ("\t\t{"); if (interface_vms.Count > 0) {