Specified class size for type 'AppWindow' is smaller than the parent type's 'HdyApplicationWindow' class size

Hello everyone- I have been working on porting an app to libhandy, and it threw this error at me (mentioned in the title). The UI is set up fine, it seems to be an error in the C code (I converted all types from GtkApplicationWindow → HdyApplicationWindow). Could anybody offer any insight into what this error means? Thanks so much.

The class structure needs to contain the parent class as its first member. You’ll want to check your AppWindowClass struct and make sure it has a HdyApplicationWindowClass. You may also need to update any G_DEFINE_TYPE or G_DECLARE_TYPE macros to refer to the correct parent class too.

And how would I do that, exactly? Sorry- I’m a beginner to GTK C.

You should probably read the GObject tutorial.

In general, you want to use the G_DECLARE_DERIVABLE_TYPE or the G_DECLARE_FINAL_TYPE macros in your header files, and the G_DEFINE_TYPE macro in your source file; these macros cut down the boilerplate, and ensure you’re doing the right thing.

If you’re not using them, then you need to ensure that your instance structure and your class structure contains the parent type as their first field:

typedef struct {
  HdyApplicationWindow parent_instance;
} YourApplicationWindow;

typedef struct {
  HdyApplicationWindowClass parent_class;
} YourApplicationWindowClass;

in order to inherit the correct size and fields.

Again: the macros would save you from doing mistakes, which is why they are preferred.

1 Like

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