2012-12-12 4 views
1

Je continue d'obtenir cette erreur en essayant de compiler un peu de code que j'ai écrit, avec l'emplacement dans le fichier étant totalement inutile. Cela utilise gtk 2.0.ANSI C erreur de compilation: expression attendue avant ',' jeton

Voici ce que je reçois au moment de la compilation:

[email protected]:~/Documents/C89$ gcc -x c -ansi -g bahbahbah.c -o bahbahbah pkg-config --cflags --libs gtk+-2.0

bahbahbah.c: In function ‘main’:

bahbahbah.c:28:1: error: expected expression before ‘,’ token

Voici le code que je suis en train de compiler:

#include <stdio.h> 
#include <stdlib.h> 
#include <gtk/gtk.h> 

#define EXIT_SUCCESS 0 
#define EXIT_FAILURE 1 

void closure(void) 
{ 
    gtk_main_quit(); 
    printf("gtk_main_quit() has been called.\n"); 
} 

void main(int argc, char* argv[]) 
{ 
    gboolean check = gtk_init_check(&argc, &argv); 
    if (check == FALSE) 
    { 
     printf("Failed to initialize toolkit.\nTerminating.\n"); 
     exit(EXIT_FAILURE); 
    } 
    else 
    { 
     printf("Initialized toolkit.\n"); 
     GtkWidget* main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
     gtk_window_set_title((GtkWindow*)main_window, "BLAH"); 
     gtk_window_set_default_size((GtkWindow*)main_window, 700, 700); 
     g_signal_connect(main_window, "delete-event", closure, void); 
     gtk_widget_show(main_window); 
     printf("Window created, sleeping in gtk_main().\n"); 
     gtk_main(); 
    }  
    printf("Exiting.\n"); 
    exit(EXIT_SUCCESS); 
} 

S'il vous plaît aider. :(

+1

g_signal_connect (main_window, "d elete-event ", fermeture, nulle); ce vide est-il censé être nul? Qu'est-ce que la ligne 28? –

+1

Je pense que c'est le problème. Changer void => NULL –

Répondre

5

Utilisez NULL remplacer void dans la ligne 28.

g_signal_connect(main_window, "delete-event", closure, NULL); 
0

void est un Key-word Il est de décrire g_signal_connect():

#define    g_signal_connect(instance, detailed_signal, c_handler, data) 

Connects a GCallback function to a signal for a particular object. 

The handler will be called before the default handler of the signal. 

instance : 
    the instance to connect to. 

detailed_signal : 
    a string of the form "signal-name::detail". 

c_handler : 
    the GCallback to connect. 

data : 
    data to pass to c_handler calls. 

Returns : 
    the handler id 

Donc, vous voulez juste passer rien à ce Ensuite, vous devez utiliser NULL

Questions connexes