Gtk and C++ ?



Is it possible to use gtk in a C++ program ??

I've tried this sample :

// BEGIN

#include <gtk/gtk.h>

void main(int argc, char *argv[])
{
  GtkWidget *Dialogue, *Label, *Bouton;
 

  gtk_init(&argc, &argv);

  // Fenetre principale
  Dialogue = gtk_dialog_new();
  gtk_window_set_title(GTK_WINDOW(Dialogue), "Hello, World");
  gtk_widget_show(Dialogue);
 
  // Le label "Hello World"
  Label = gtk_label_new("Bonjour, World");
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Dialogue)->vbox), Label, TRUE, TRUE, 0);
  gtk_widget_show(Label);
 
  // Le bouton Fermer
  Bouton = gtk_button_new_with_label("Fermer");

  gtk_signal_connect_object(GTK_OBJECT(Bouton), "clicked", (GtkSignalFunc)gtk_exit,
NULL);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Dialogue)->action_area), Bouton, TRUE,
TRUE, 0);
  gtk_widget_show(Bouton);
 
  gtk_main();
 
 
  gtk_main();
}

// END

and when I use gcc to compile, it raises the following error :

hellogtk.cpp: In function `int main(...)':
hellogtk.cpp:21: ANSI C++ forbids implicit conversion from `void *' in argument passing
 

Thank you for your help,

--
Cyril PICARD
mailto:cyril.picard@matranortel.com
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]