On Sun, Oct 07, 2012 at 05:43:52PM +0200, Arne Pagel wrote: > because of my lazy programming style I sometimes forget or overwirte > the comma before the -1 end of line marker for the gtk_tree_model_get > or gtk_tree_store_set function. This error can usually not be > detected by the c-compilers, so that I had to spend some really > unnecessary time to fix this typo. > > Now I defined a makro for this, and in the case I forget the comma > again at least I get a compiler error: > > #define TREE_MODEL_EOL (int)-1 > > gtk_tree_model_get(model,iter,STUFF,&stuff,TREE_MODEL_EOL); > > I think something like this would be integrated officially and also > the all the examples would be updated, at lot of headache of many > people could be avoided.
Errors related to the -1 sentinel could be avoided by much more straightforward means: defining gtk_tree_model_get() with column id and value pointer reversed, i.e. first comes the value pointer (presumably non-NULL), then comes the column id. Then gtk_tree_model_get() could just carry __attribute__((sentinel)) a.k.a. G_GNUC_NULL_TERMINATED. But the Gtk+ devs decided otherwise. It would be nice (also in other cases) if gcc had an attribute for arbitrary constant-value sentinels. Unfortunately, it has not. The corresponding bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28319 seems to be stale. I'm not sure about LLVM but it does not seem to support this either. While I've never forget the comma before -1 I have forgetten the -1 entirely a few times so something that prevents all sentinels errors would be quite useful. Yeti _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list