quick question. Am I reading this right?

Discussion in 'C Programming' started by halfmaddad, Apr 25, 2014.

  1. halfmaddad

    halfmaddad Guest

    Hi Everyone

    I have encountered this snippet of code:
    screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;

    Is this correct, the results from xcb_get_setup are fed to xcb_setup_roots_iterator and the result from this is a struct. And this struct's "data" member is then assigned to screen ?

    Thanks for reading-Patrick
     
    halfmaddad, Apr 25, 2014
    #1
    1. Advertisements

  2. Exactly. More precisely: the result from xcb_get_setup [of type
    "const xcb_setup_t *"] are fed to xcb_setup_roots_iterator and the
    result from this is a struct [of type "xcb_screen_iterator_t"]. And this
    struct's "data" member [of type "xcb_screen_t *"] is then assigned to
    screen ?

    Here are the relevant declarations from xcb.h and xproto.h
    (in /usr/include/xcb on my box), both being fairly well documented:

    const xcb_setup_t *xcb_get_setup(xcb_connection_t *c);

    xcb_screen_iterator_t xcb_setup_roots_iterator (const xcb_setup_t *R);

    typedef struct xcb_screen_iterator_t {
    xcb_screen_t *data;
    int rem;
    int index;
    } xcb_screen_iterator_t;

    -- Alain.
     
    Alain Ketterlin, Apr 25, 2014
    #2
    1. Advertisements

  3. halfmaddad

    James Kuyper Guest

    Yes.
     
    James Kuyper, Apr 25, 2014
    #3
  4. halfmaddad

    halfmaddad Guest

    thanks Alain ! Thanks James !

    Have a great day
     
    halfmaddad, Apr 25, 2014
    #4
  5. Yes. (It's conceivable, but unlikely, that xcb_setup_roots_iterator()
    returns a union rather than a struct.)

    My only quibble is that I'd say "result" rather than "results".
     
    Keith Thompson, Apr 25, 2014
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.