home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xco212p.zip / SAMPLES / CSET / cmain.c < prev    next >
C/C++ Source or Header  |  1995-12-04  |  1KB  |  39 lines

  1. /*
  2.   Example of multi-language programming: M2 and C functions in one program
  3. */
  4.  
  5. #include <stdio.h>
  6. #include "m2test.h"
  7.  
  8. #define GCAUTO          1
  9. #define HEAPLIMIT       4000000
  10. #define GCTHRESHOLD     2000000
  11.  
  12. extern void X2C_BEGIN(int *argc, char **argv,
  13.                       int gcauto, long gcthreshold, long heap_limit);
  14. extern void X2C_InitFPP(void);
  15. extern void X2C_NATIVE_BEGIN(void);
  16. extern void X2C_INIT_HISTORY(void);
  17. extern void X2C_EXIT(void);
  18.  
  19. void cfunc(void)
  20. {
  21.         printf("Calling Modula-2 function with C calling conventions\n");
  22.         printf("Result is %d (expected 4)\n",m2func(2,2));
  23. }
  24.  
  25. int main(int argc, char **argv)
  26. {
  27.         X2C_InitFPP();       /* if program uses floating point */
  28.         X2C_NATIVE_BEGIN();  /* always */
  29.         X2C_INIT_HISTORY();  /* if GENHISTORY+ */
  30.         X2C_BEGIN(&argc,argv,GCAUTO,GCTHRESHOLD,HEAPLIMIT); /* always */
  31. /* call M2/O2 module's bodies */
  32.         m2test_BEGIN();
  33. /* C code begin */
  34.         cfunc();
  35. /* C code end */
  36.         X2C_EXIT();          /* will never return */
  37.     return 0;
  38. }
  39.