home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / os9 / 1514 < prev    next >
Encoding:
Text File  |  1992-12-11  |  1.5 KB  |  59 lines

  1. Path: sparky!uunet!usc!hela.iti.org!cs.widener.edu!dsinc!netnews.upenn.edu!ginger.biophys.upenn.edu!mark
  2. From: mark@ginger.biophys.upenn.edu (Mark Elliott)
  3. Newsgroups: comp.os.os9
  4. Subject: Can't get OS-9 C to use procedures as variables!!!
  5. Message-ID: <101675@netnews.upenn.edu>
  6. Date: 11 Dec 92 20:36:51 GMT
  7. Sender: news@netnews.upenn.edu
  8. Organization: University of Pennsylvania
  9. Lines: 47
  10. Nntp-Posting-Host: ginger.biophys.upenn.edu
  11.  
  12.  
  13.     I have OS-9 v2.4 on a 68030 (MVME 147) machine. My "CC" module says
  14. that it is Edition #40. The following code crashes (with BUS ERROR) when I run
  15. it. On other Unix machines, it runs fine.
  16.  
  17. /****************************************************************************/
  18. typedef struct
  19. {
  20.     int    (*subfunc)();
  21.     int    x;
  22. } teststruct;
  23.  
  24.  
  25. main()
  26. {
  27.     teststruct    test;
  28.     int        sayhello();
  29.     
  30.     test.x = 5;
  31.     test.subfunc = *sayhello;
  32.     
  33.     test.subfunc(&test);    /*** <--- THIS IS WHERE OS-9 CRASHES ***/
  34.     
  35.     exit(0);
  36.     
  37. }
  38.  
  39. int sayhello(test)
  40. teststruct  *test;
  41. {
  42.     printf("Hello. # = %1d\n", test->x);
  43. }
  44. /****************************************************************************/
  45.  
  46.     As this program does, I would like to assign a procedure to a variable 
  47. and later call this procedure via the variable value. Does anyone know why this
  48. fails?
  49.     Thanks in advance.
  50.  
  51.  
  52.  
  53. Mark Elliott                       |     
  54. Dept of Radiology                  |     Voice: (215) 898-9357
  55. University of Pennsylvania         |     FAX  : (215) 573-2113
  56. Philadelphia, PA 19104 USA         |     Email: mark@ginger.biophys.upenn.edu
  57.  
  58.  
  59.