Function with two or more entry point

sztfg@yandex.ru sztfg@yandex.ru
Tue Mar 12 20:17:00 GMT 2013


It is possible to make function that have two or more entry points?
Something like this:

#include <stdio.h>

void test_print1()
{
  printf("print1\n");
  void test_print2()
  {
    printf("print2\n");
  }
}

int main ()
{
  test_print1();
  test_print2();

  return 0;
}

I also tried this:

#include <stdio.h>
#include <stddef.h>

void test_print1()
{
  entry0:
  printf("print1\n");
  entry1:
  printf("print2\n");
}

const ptrdiff_t ent1_m_ent0 =  (&&entry1 - &&entry0);

int main ()
{
  test_print1();
  (*(void(*)())(char *)(test_print1)+ ent1_m_ent0 )();
  return 0;
}

... but it doesn't work



More information about the Gcc-help mailing list