GCC labels as values extension and scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For example, this code

#include <stdio.h>

void *labels[3];

void test(void *ptr)
{
    if(ptr == NULL)
    {
      labels[0] = &&l1;
      labels[1] = &&l2;
      labels[2] = &&l3;
      return;
    }
    goto *ptr;
l1:
    printf("test1\n");
    return;
l2:
    printf("test2\n");
    return;
l3:
    printf("test3\n");
    return;
}

int main(void)
{
   test(NULL);
   test(labels[0]);
   test(labels[1]);
   test(labels[2]);
}

It is possible to get label pointer without adding this if(ptr == NULL) { blah-blah } stuff and global array? Something like:

test(test.l1);
test(test.l2);
test(test.l3);



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux