GCC Extensions

Jump to: navigation, search

GCC Extensions Used in the Wild

     typedef union __attribute__ ((__transparent_union__))
              int *__ip;
              union wait *__up;
            } wait_status_ptr_t;
          pid_t wait (wait_status_ptr_t);

This interface allows either int * or union wait * arguments to be passed, using the int * calling convention. The program can call wait with arguments of either type:

          int w1 () { int w; return wait (&w); }
          int w2 () { union wait w; return wait (&w); }

With this interface, wait's implementation might look like this:

          pid_t wait (wait_status_ptr_t p)
            return waitpid (-1, p.__ip, 0);

See Also


blog comments powered by Disqus