Empty string is null?

Mike Wey mike-wey at example.com
Sun May 31 06:24:01 PDT 2009


hasen wrote:
> How to pass it to C functions that expect a non-null string? 
> Specifically to GTK+ (using gtkD)
> 
> I also asked this on stackoverflow 
> http://stackoverflow.com/questions/931360/
> 
>    ------------
> 
> Using D1 with phobos
> 
> I have a text entry field, instance of gtk.Entry.Entry,
> 
> calling setText("") raises a run time error
> 
>   Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed
> 
> Why? It seems to be a problem with D, I tried this:
> 
>   string empty = "";
>   assert (empty != null);
>   my_entry.setText(empty)
> 
> The program terminated as the assertion failed.
> 
> How can I work around this?
> 

As a workaround you could use setText("\0");
This shouldn't be needed in GtkD svn r685.

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list