GNOME Bugzilla – Bug 652310
Constant string array is not constant in C code
Last modified: 2018-02-26 09:50:25 UTC
When I use a function wich have as C argument: const gchar** So in vala code I call this function like this: func({ "some string" }); But this code cause a gcc & Clang/LLVM warning (for Gtk.AboutDialog.set_authors): src/about.c:89:56: warning: passing 'gchar **' (aka 'char **') to parameter of type 'const gchar **' (aka 'const char **') discards qualifiers in nested pointer types gtk_about_dialog_set_authors ((GtkAboutDialog*) self, _tmp5_); ^~~~~~ In file included from src/about.c:7: In file included from /usr/include/gtk-2.0/gtk/gtk.h:33: /usr/include/gtk-2.0/gtk/gtkaboutdialog.h:112:26: note: passing argument to parameter 'authors' here ...const gchar **authors); In C code, a new temporary variable is created, but it's useless ! I tested two ways to fix this: 1) A local constant array 2) A class/global constant array The fist way produce a gcc & Clang/LLVM error: src/about.c:63:28: error: initializer element is not a compile-time constant static const gchar* a[] = {_tmp0_}; The second way works but it's not optimised ! (use a C static variable) Note: I use Clang/LLVM for warnings and errors because it's more detailed.
*** This bug has been marked as a duplicate of bug 622708 ***