Offer to help with tutorial(s)

I finally got my first Gtk window to open following Gtk – 4.0: Getting Started with GTK and it occurred to me that what I learned (by the corrections I made) might be interesting to others. How do I send suggestions for either correction or at least review by someone more knowledgeable than I?

1 Like

That’s wonderful that you want to contribute back to the tutorial!

I see it’s not obvious on where to go for the source, but I found it at docs/reference/gtk/ · main · GNOME / gtk · GitLab. I’m sure a merge request would be appreciated there.

1 Like

My offer is still valid but it may be moot. My workstation of choice is a Macbook (MacOS 13.3.1) with the Apple M2 chip. This morning I tried the tutorial examples 0 and 4 on my Ubuntu workstation and of course it built correctly without the surprises I had on my Mac. Do you care about such differences? To clarify, there are two changes needed:

  1. the compile command needs “–std=c11” if using the built-in gcc, which is clang 14.0.3 and defaults to C99.

  2. “gtk_widget_show (window);” changes to “gtk_widget_set_visible (window, true);” because of a deprecation.

What’s not clear to me is whether OS-specific differences merit any attention.

I also have at hand an Intel-silicon Mac and a relatively unused Windows 10, so I can do a lot of platform comparisons. I’m having a challenge getting logged in to Gitlab.

Gitlab access issue resolved.

Whether OS-specific differences should be highlighted, depends on the goal of the tutorial. But I’m not sure these are OS-specific:

I believe only C99 is required for the GNOME platform. Can you say more about what part of the tutorial required C11? I don’t know what the preference of the tutorial’s author would be, but arguably either the tutorial should compile using -std=c11 on both GCC and Clang if there’s C11 features used in it.

This seems like a question of what version of GTK is used to complete the tutorial. Ideally I’d guess the tutorial should be based on the latest version.

My interest in GTK arises from a desire for a multi-language, multi-platform, non-commercial GUI framework, and I’m not currently involved in Gnome development (but I’ve learned to not limit the future).

The errors arise on the very fist demo, example-0.

Below is the pertinent part of the first of eight errors that pop up by running the tutorial’s recommended compile command, gcc $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs gtk4) Adding the -std=c11 option cleaned up all that. I can give you the entire output if you like.

I just yesterday discovered a great virtual machine (UTM) for running ubuntu 2023.4 on my M2 Mac, so I just now repeated example-0 from a clean slate in Ubuntu 23.04, and the one change I needed was t change to gtk_widget_set_visible.

I’m looking for a way to probe the two complers to see what their default c std level is. I saw a site that said c11 was the GNU standard , and the GNU gcc defaults to that, so it’s to be expected that using a different compiler is at the user’s risk.

Head of compiler output (Note explanation of ‘GtkBuilderScope’):

In file included from /opt/homebrew/Cellar/gtk4/4.10.3_1/include/gtk-4.0/gtk/gtkbuilder.h:26:
/opt/homebrew/Cellar/gtk4/4.10.3_1/include/gtk-4.0/gtk/gtkbuilderscope.h:34:22: error: redefinition of typedef 'GtkBuilderScope' is a C11 feature [-Werror,-Wtypedef-redefinition]
G_DECLARE_INTERFACE (GtkBuilderScope, gtk_builder_scope, GTK, BUILDER_SCOPE, GObject)

I’d suggest that the default -std level is irrelevant here; in your testing, it sounds like GCC accepts use of that C11 feature without complaint, and Clang does not.

It looks like that error actually originates in a GTK header file. Here are the details on which C features are required for compiling GLib applications (and therefore, the whole GNOME platform.) C11 Redefinition of typedef is, according to that doc, not required to be supported in the compiler, although it will be in the future. Assuming you’re not using an old version of GTK after which that header file was subsequently fixed (though 4.10.3 is pretty recent), it seems to me that one of two things could be happening:

  • The doc page could be out of date, and the future when the C11 feature is required has already arrived. In that case the tutorial should probably be instructing you to compile with -std=c11 regardless of whether your compiler is GCC or Clang.
  • The gtkbuilderscope.h file could be using the C11 feature when it’s not supposed to. That would be a bug in GTK.

In the former case you could submit a merge request to GLib to update the doc page, and one to GTK to add the -std=c11 to the tutorial. In the latter case you could open a ticket in GTK or even a merge request to fix it. The trick is telling which one it is. I’d suggest joining the GTK chat: There you can ask for opinions on which case it might be.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.