Pelles C forum

C language => Expert questions => Topic started by: akko on August 04, 2011, 12:52:22 PM

Title: Simulate computed goto in Pelles C
Post by: akko on August 04, 2011, 12:52:22 PM
Hi
(I know it is not in the standard but...)
has anybody tried to mimick computed gotos in Pelles C by some smart inline assembler macro?
(I want to build a direct threading virtual machine but the classic giant switch seems too slow)

This works in MinGW (and should in MSVC too):

/* oolala.c */
#include <stdio.h>
#include <stdlib.h>

int main(void)
{   int i = 0;
   void *p = &&l_addr;

   printf("oo");
l_addr:
   printf("la");
   if (++i < 2) goto *p;
   return(0);
}