changeset 325:68adc3a367d9

Better static asserts to detect changing .stringof format
author Frank Benoit <benoit@tionex.de>
date Tue, 07 Oct 2008 18:13:28 +0200
parents 174bd206cf10
children f979673f7d47 92aa2d7391f3
files dwt/internal/gtk/OS.d
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/gtk/OS.d	Tue Oct 07 17:50:07 2008 +0200
+++ b/dwt/internal/gtk/OS.d	Tue Oct 07 18:13:28 2008 +0200
@@ -616,12 +616,18 @@
 template NameOfFunc(alias f) {
     // Note: highly dependent on the .stringof formatting
     // the value begins with "& " which is why the first two chars are cut off
+
+    // this is also used in dwt/internal/cairo/Cairo and dwt/internal/accessible/gtk/ATK
     version( LDC ){
-        // stringof in LLVMDC is "&foobar"
+        // stringof in LDC is "&foobar"
+        static assert( (&f).stringof[0] == '&' );
+        static assert( (&f).stringof[1] != ' ' );
         const char[] NameOfFunc = (&f).stringof[1 .. $];
     }
     else{
         // stringof in DMD is "& foobar"
+        static assert( (&f).stringof[0] == '&' );
+        static assert( (&f).stringof[1] == ' ' );
         const char[] NameOfFunc = (&f).stringof[2 .. $];
     }
 }