title: Borland style __closure in gcc
body: <p>I am new in programming with gnu C++. I have an application which I thought to be converted to cross platform and I began to use C::B about two months ago. I had many problems but I solved them keeping original code in <code>#ifdef BCB ... #else ... #endif</code> blocks for objects classes or structs. I am not able to solve the following problem because it is very complicated. The function declarations have been working since 1997/1998 and every point of the application(s) was developed relying on these definitions and implementations. They are used for inter-object, inter-process,  and network communication and all interactive event system. Any function anywhere can be called with any number (up to 50) of parameters directly, or via stream connections as long as our JetRtl.dll is ready to serve and caller knows the number of parameters. I explained so long because as far as I see, many people simply ask "Why ...", or give childish solution to be worked only in "Hello World" apps. </p>
  
  <p>Here is the header file. <code>#else .... #endif</code> section has been recently added. </p>
  
  <pre><code>#ifndef fcalls_h
  #define fcalls_h
  
  #include &lt;jettip.h&gt;
  #include &lt;stdarg.h&gt;
  
  //  CM_FN_.. calls non member F(...), (ecx &amp; 4) == 0
  #define CM_FN_C 0x8FF0 // __cdecl non member F(...)
  #define CM_FN_F 0x8FF1 // __fastcall non member F(...)
  #define CM_FN_P 0x8FF2 // __pascal non member F(...)
  #define CM_FN_S 0x8FF3 // __stdcall non member F(...)
  
  //  CM_FNX.. calls  member X::F(...), (ecx &amp; 4) == 4
  #define CM_FNXC 0x8FF4 // __cdecl member X::F(...)
  #define CM_FNXF 0x8FF5 // __fastcall member X::F(...)
  #define CM_FNXP 0x8FF6 // __pascal member X::F(...)
  #define CM_FNXS 0x8FF7 // __stdcall member X::F(...)
  
  #define CM_TERK 0xFFFE // Quits message loop
  #define CM_DELW 0x8FFF // destroy link window
  
  typedef void __cdecl    (*JF_C)();
  #ifdef BCB
  typedef void __cdecl    (__closure *JFXC)();
  #else
  template&lt;class T&gt; class FXT{};
  template&lt;class R&gt; class FXT&lt;R()&gt;{};
  template&lt;class R,class A&gt; class FXT&lt;R(A)&gt;{};
  template&lt;class R,class A,class B&gt; class FXT&lt;R(A,B)&gt;{};
  template&lt;class R,class A,class B,class C&gt; class FXT&lt;R(A,B,C)&gt;{};
  template&lt;class R,class A,class B,class C,class D&gt; class FXT&lt;R(A,B,C,D)&gt;{};
  template&lt;class R,class A,class B,class C,class D, class E&gt; class FXT&lt;R(A,B,C,D,E)&gt;{};
  template&lt;class R,class A,class B,class C,class D, class E,class F&gt; class FXT&lt;R(A,B,C,D,E,F)&gt;{};
  template&lt;class R,class A,class B,class C,class D, class E,class F,class G&gt; class    FXT&lt;R(A,B,C,D,E,F,G)&gt;{};
  
  typedef FXT&lt;void __cdecl (void*)&gt; JFXC;
  #endif
  
  JF_C __cdecl F_CP(...);
  JFXC __cdecl FXCP(...);
  JF_C __cdecl _F_CP(int yer, ...);
  JFXC __cdecl _FXCP(int yer, ...);
  
  long __fastcall RunFN_C(va_list list, long args);
  long __fastcall RunFN_F(va_list list, long args);
  long __fastcall RunFN_P(va_list list, long args);
  long __fastcall RunFN_S(va_list list, long args);
  
  long __fastcall RunFNXC(va_list list, long args);
  long __fastcall RunFNXF(va_list list, long args);
  long __fastcall RunFNXP(va_list list, long args);
  long __fastcall RunFNXS(va_list list, long args);
  
  // Dispatches the function call into appropirate function; fnx(list, args)
  long  __fastcall JetTip DispCall(va_list list, long args, int call);
  
  #endif
  </code></pre>
  
  <p>The big question is <em>"How can I make GCC (MinGW 4.71, I also have 4.92) to understand the expression <code>typedef void __cdecl    (__closure *JFXC)();</code>?"</em></p>
  
  <p>Expressions without <code>__closure</code> compiles and works as expected.</p>