MULTI1.C 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma warn(wall=>on)
  2. #include <stdio.h>
  3. #include <mio.h>
  4. #include <multi2.h>
  5. /* routine to be called from Modula using Modula conventions (see multi1.def) */
  6. #pragma save, name(prefix=>"multi1$"), call(c_conv=>off)
  7. void x(long a,long b,long c,long d){
  8. printf("multi1.x called: a=%ld,b=%ld,c=%ld,d=%ld\n",a,b,c,d);
  9. p(a,b,c,d);
  10. }
  11. #pragma restore
  12. /* routine to be called from Modula using C conventions (see multi1.def) */
  13. void y(long a,long b,long c,long d){
  14. printf("multi1.y called: a=%ld,b=%ld,c=%ld,d=%ld\n",a,b,c,d);
  15. q(a,b,c,d);
  16. }
  17. /* initialisation routine, which will be called before main module is executed */
  18. static void init(){
  19. printf("multi1.init called\n");
  20. IO$WrStr(25,"IO.WrStr called from 'C'");
  21. IO$WrLn();
  22. }
  23. /* example of how to do modula style initialisation in 'C' */
  24. #pragma save, name(prefix=>"") /* have to use Modula naming convention */
  25. #define NSUB 2 /* number of sub-modules called from this module */
  26. #ifdef _fdata
  27. #define INITDATA far
  28. #else
  29. #define INITDATA near
  30. #endif
  31. extern char INITDATA multi2$[], INITDATA IO$[];
  32. /* list of sub-modules called from this module */
  33. struct { void (*initfunc)(void); char INITDATA *sub[NSUB]; int term; } multi1$ =
  34. { init, /* initialisation routine */
  35. multi2$, IO$, /* list of sub-modules called from this module */
  36. -1 /* terminator */
  37. };
  38. #pragma restore
  39. /* link in multi2.obj (alternatively insert the line 'include multi2' in project file multi.prj)*/
  40. #pragma link(multi2)
  41.