xlib example - X

This is a discussion on xlib example - X ; Dear All! I have the following code, which produces segmentation fault. Any reasons why? #include #include #include #include #include #include #include struct Server_class{ Display *dpy; Window win; Window root; Pixmap pm; GC gc; } *app; void setup_connection(){ app->dpy = XOpenDisplay(NULL); ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: xlib example

  1. xlib example

    Dear All!

    I have the following code, which produces segmentation fault.
    Any reasons why?


    #include
    #include
    #include
    #include
    #include
    #include
    #include
    struct Server_class{
    Display *dpy;
    Window win;
    Window root;
    Pixmap pm;
    GC gc;
    } *app;
    void setup_connection(){
    app->dpy = XOpenDisplay(NULL);
    printf("Hello\n");
    }
    int main(){
    setup_connection();
    return 0;
    }


  2. Re: xlib example

    eotcl schrieb:
    > Dear All!
    >
    > I have the following code, which produces segmentation fault.
    > Any reasons why?
    >
    >
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > struct Server_class{
    > Display *dpy;
    > Window win;
    > Window root;
    > Pixmap pm;
    > GC gc;
    > } *app;
    > void setup_connection(){
    > app->dpy = XOpenDisplay(NULL);
    > printf("Hello\n");
    > }
    > int main(){
    > setup_connection();
    > return 0;
    > }
    >

    Where ara you allocating space for app?

    Lars

+ Reply to Thread