redefinition of "class GtkwidgetDef"

138 Views Asked by At

I really don't know why i have this redefinition error

GtkwidgetDef.h

#include <gtk/gtk.h>
class GtkwidgetDef
{
public:
    GtkWidget* display;
    GtkwidgetDef(GtkButton* button);
};

GtkwidgetDef.cpp

#include "GtkwidgetDef.h"
extern "C" GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widgetName);

GtkwidgetDef::GtkwidgetDef(GtkButton* button){
display = lookup_widget(GTK_WIDGET(button), "display");
}

these two fonctions are juste definition and constructor

MesFonctions.cpp

#include "MesFonctions.h"
#include <math.h>
string str;
gchar str1[9] = "";

void showText(GtkwidgetDef widgets, gchar* label)
{
gtk_entry_set_text(GTK_ENTRY(widgets->display), label);
}
.........

CALCU.h

#include <gtk/gtk.h>
typedef enum Event{ SEVEN_CLICKED, PLUS_CLICKED, VALIDE } Event;

int processEvent(Event e, GtkButton* button);

CALCU.cpp

#include "CALCU.h"
#include "MesFonctions.h"
#include "GtkwidgetDef.h"

int processEvent(Event e, GtkButton* button)
{
//GtkwidgetDef* widgets = new GtkwidgetDef();   
//label = gtk_button_get_label(button);
GtkwidgetDef widgets(button);
gchar* label;
strcpy(label, gtk_button_get_label(button));

string s;
switch(e)
{
    case SEVEN_CLICKED:
        //showText(*widgets, label);
        showText(widgets, label);
        s = "7";
        pushValue(s);
        break;
    case PLUS_CLICKED:
        //showText(*widgets, label);
        showText(widgets, label);
        s = "+";
        pushValue(s);
        break;
    case VALIDE:
        showResult();
        break;
}
}

i wonder if i make an error here in this line GtkwidgetDef widgets(button);

1

There are 1 best solutions below

0
On

I think the reason you are seeing this is that you include GtkwidgetDef.h twice at some point: once directly and once indirectly. You probably need to add an include guard to your header:

#ifndef GtkwidgetDef_h
#define GtkwidgetDef_h

#include <gtk/gtk.h>
class GtkwidgetDef
{
public:
    GtkWidget* display;
    GtkwidgetDef(GtkButton* button);
};

#endif