tags:

views:

107

answers:

1

that is how I build it: gcc pkg-config --cflags --libs gtk+-2.0 -o spawn spawn_with_pipes.c

In the snippet of example below, I get an error: syntax error before "Data - it refers to data= g_slice_new(Data);

#include <gtk/gtk.h>

typedef struct
{
    /* Buffers that will display output */
    GtkTextBuffer *out;
    GtkTextBuffer *err;

    /* Progress bar that will be updated */
    GtkProgressBar *progress;

    /* Timeout source id */
    gint timeout_id;
}Data;

data= g_slice_new(Data); //error here
+1  A: 

Initalisers outside of a function must be constant expressions. You can't call a function within them.

In addition, the variable "data" in your code is an int and the return of g_slice_new is a gpointer.

You will need to change the definition of "data" and move the initialisation into main:

gpointer data;

int main(int argc, char *argv[])
{
    ...
    data = g_slice_new(Data);
caf