home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!hela.iti.org!cs.widener.edu!dsinc!netnews.upenn.edu!ginger.biophys.upenn.edu!mark
- From: mark@ginger.biophys.upenn.edu (Mark Elliott)
- Newsgroups: comp.os.os9
- Subject: Can't get OS-9 C to use procedures as variables!!!
- Message-ID: <101675@netnews.upenn.edu>
- Date: 11 Dec 92 20:36:51 GMT
- Sender: news@netnews.upenn.edu
- Organization: University of Pennsylvania
- Lines: 47
- Nntp-Posting-Host: ginger.biophys.upenn.edu
-
-
- I have OS-9 v2.4 on a 68030 (MVME 147) machine. My "CC" module says
- that it is Edition #40. The following code crashes (with BUS ERROR) when I run
- it. On other Unix machines, it runs fine.
-
- /****************************************************************************/
- typedef struct
- {
- int (*subfunc)();
- int x;
- } teststruct;
-
-
- main()
- {
- teststruct test;
- int sayhello();
-
- test.x = 5;
- test.subfunc = *sayhello;
-
- test.subfunc(&test); /*** <--- THIS IS WHERE OS-9 CRASHES ***/
-
- exit(0);
-
- }
-
- int sayhello(test)
- teststruct *test;
- {
- printf("Hello. # = %1d\n", test->x);
- }
- /****************************************************************************/
-
- As this program does, I would like to assign a procedure to a variable
- and later call this procedure via the variable value. Does anyone know why this
- fails?
- Thanks in advance.
-
-
-
- Mark Elliott |
- Dept of Radiology | Voice: (215) 898-9357
- University of Pennsylvania | FAX : (215) 573-2113
- Philadelphia, PA 19104 USA | Email: mark@ginger.biophys.upenn.edu
-
-
-