GCC labels as values extension and scope
sztfg@yandex.ru
sztfg@yandex.ru
Tue Apr 11 15:03:00 GMT 2017
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);
More information about the Gcc-help
mailing list