home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.os9
- Path: sparky!uunet!mcrware!jejones
- From: jejones@microware.com (James Jones)
- Subject: Re: Can't get OS-9 C to use procedures as variables!!!
- Message-ID: <1992Dec12.134523.27549@microware.com>
- Sender: news@microware.com
- Nntp-Posting-Host: snake
- Organization: Microware Systems Corp., Des Moines, Iowa
- References: <101675@netnews.upenn.edu>
- Date: Sat, 12 Dec 1992 13:45:23 GMT
- Lines: 32
-
- In article <101675@netnews.upenn.edu> mark@ginger.biophys.upenn.edu (Mark Elliott) writes:
- > 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;
-
- [Remaining code omitted...]
-
- Leaving the * off in the assignment above should make the program work.
- A subtlety of the ANSI C standard makes it possible to throw in as many
- asterisks as you'd like and still assign the address of sayhello, and
- in fact the Ultra C compiler will cheerfully take
-
- test.subfunc = ******sayhello;
-
- and do just that. (You would, of course, have to include <stdio.h>
- since you're using printf.)
-
- James Jones
-