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

  1. Newsgroups: comp.os.os9
  2. Path: sparky!uunet!mcrware!jejones
  3. From: jejones@microware.com (James Jones)
  4. Subject: Re: Can't get OS-9 C to use procedures as variables!!!
  5. Message-ID: <1992Dec12.134523.27549@microware.com>
  6. Sender: news@microware.com
  7. Nntp-Posting-Host: snake
  8. Organization: Microware Systems Corp., Des Moines, Iowa
  9. References: <101675@netnews.upenn.edu>
  10. Date: Sat, 12 Dec 1992 13:45:23 GMT
  11. Lines: 32
  12.  
  13. In article <101675@netnews.upenn.edu> mark@ginger.biophys.upenn.edu (Mark Elliott) writes:
  14. >    I have OS-9 v2.4 on a 68030 (MVME 147) machine. My "CC" module says
  15. >that it is Edition #40. The following code crashes (with BUS ERROR) when I run
  16. >it. On other Unix machines, it runs fine.
  17. >
  18. >typedef struct
  19. >{
  20. >    int    (*subfunc)();
  21. >    int    x;
  22. >} teststruct;
  23. >
  24. >main()
  25. >{
  26. >    teststruct    test;
  27. >    int        sayhello();
  28. >    
  29. >    test.x = 5;
  30. >    test.subfunc = *sayhello;
  31.  
  32. [Remaining code omitted...]
  33.  
  34. Leaving the * off in the assignment above should make the program work.
  35. A subtlety of the ANSI C standard makes it possible to throw in as many
  36. asterisks as you'd like and still assign the address of sayhello, and
  37. in fact the Ultra C compiler will cheerfully take
  38.  
  39.     test.subfunc = ******sayhello;
  40.  
  41. and do just that.  (You would, of course, have to include <stdio.h>
  42. since you're using printf.)
  43.  
  44.     James Jones
  45.