Thank you, Emmanuele. It works if I put the macro in my compilation unit, however it does not work if I put the macro in the header.
As I said, I never registered custom types, so I have no idea about the machinery. What if two different compilation units need to use the same GType? Do I have to copy and paste G_DEFINE_FLAGS_TYPE in every compilation unit that uses those flags? Is there not a way to put the whole thing inside a common header?
I really wanted to. I am usually an avid reader of the documentation. But concerning how to register a GType I could not find much. My first question asked for a tutorial to read.
So, imagine foo.c, which implements an object called MyFoo, that declares a bitmask property whose type is MyCustomFlags. If I put G_DEFINE_FLAGS_TYPE inside foo.c everything works fine. But now there is bar.c, which implements another object called MyBar, that also declares a bitmask property whose type is MyCustomFlags. How does the latter know about the GType if no header mentions it?
There is no tutorial on how to register a flags type, which is what you asked; I assumed you were at least in passing familiar with GObject and the type system, though, since you talked about deriving types and adding properties.
I believe I am familiar with GObject, at least most of its parts. But GTypes are something I never had to actively use, so until now for me they could be anything, they could be integers, they could be structs, etc., because I always used them passively, only when I was asked to pass a GType obtained from somewhere else.
However I see now that I had missed this from your previous message,
which makes everything clear (thank you).
So GTypes are objects too? Or are they something a bit more primitive than objects upon which objects are built?
A GType is just a number which identifies a type registration in a runtime type store (which is maintained by libgobject).
Each GObject class has a unique GType, but each GType is not necessarily a class. GTypes are also used to identify flag types, boxed types, enums, GTypeInstances (which GObjects are a subtype of), etc.
It’s a runtime implementation of a Java-style type system.
Thank you. Silly me before for asking if they are objects, I should have remembered that they are always passed by value (GType and never GType *). As I said, this is something I never had to deal with so far.
Yes, I had a glimpse of what they do, but the exact machinery was completely obscure to me.
I have another question. Actually two. What are the advantages of installing a property via g_param_spec_flags() compared to installing it via g_param_spec_uint()? And more in general, what are the advantages of having a GType for flags instead of having a simple enum?