tags:

views:

23

answers:

2

Hello,

In my gtk+ application i have function in mainwin.c:

void
on_prev( GtkWidget* btn, MainWin* mw )
{
   ...
}

And in file ui.h i have:

#include "mainwin.h"
static const GtkActionEntry entries[] = {
    {
      "Go Back",
      GTK_STOCK_GO_BACK,
      "Go Back",
      "<control>b",
      "Go Back",
       G_CALLBACK(on_prev)
    },
}

But when i try to compile this application, i see error: ui.h:error: 'on_prev' undeclared here (not in a function).

What's wrong?

Thank you.

+1  A: 

Add a prototype for it, probably in mainwin.h:

void
on_prev( GtkWidget* btn, MainWin* mw );
Matthew Flaschen
Thank you for reply, I added prototype in mainwin.h, but it did not help :(
shk
Please post the source of `mainwin.h`, and the exact error.
Matthew Flaschen
A: 

You really shouldn't have static data in a header. That means every time you include that file from a C file, you get a new, static (i.e. local to that C file) instance of the array. That is very likely not what you need.

Move the declaration and initialization of the array into a C file, and make sure the various functions it refers to are properly declared.

unwind