GTK static library warnings

Hi, I compiled GTK3 into a static library. But with warnings (-Wall , etc) on, I get many warnings in GTK code too. How can I get warnings only for my project and not any from GTK library ?

Example:

#include "gtk/gtk.h"
int main(void)
{
    return 0;
}

* Warnings on:
-------------- Build: Release in Temp (compiler: LLVM Clang Compiler 9 GTK Library)---------------
Process terminated with status 0 (0 minute(s), 12 second(s))
1 error(s), 1962 warning(s) (0 minute(s), 12 second(s))

* Warnings off:
-------------- Build: Release in Temp (compiler: LLVM Clang Compiler 10 GTK Library Warnings_Disabled)---------------
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I fixed several warnings. As a result code works fine , there is a warning though:

            recents_ptr[i]=(rf_widget); // TODO cast to ?

Warns:

/home/mehdi/Documents/Code_Blocks_Projects/Temp/Main.c:178:27: warning: incompatible pointer types assigning to 'GtkRecentInfo *' (aka 'struct _GtkRecentInfo *') from 'GtkWidget *' (aka 'struct _GtkWidget *') [-Wincompatible-pointer-types]
            recents_ptr[i]=(rf_widget); // TODO cast to ?
                          ^~~~~~~~~~~~

A GtkWidget is not a GtkRecentInfo, so you cannot store a GtkWidget pointer into an array of pointers to GtkRecentInfo. The compiler is telling you that you’re doing such an assignment.

You must cast explicitly to the array’s element type: (GtkRecentInfo *).

No, not really; if you try to store a widget inside a GtkRecentInfo array you’re going to have a bad time.

I mean: it’s all pointers in the end, but then: why have types at all?

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