home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!newsserver.pixel.kodak.com!laidbak!tellab5!sdc!kenk
- From: kenk@sdc.com (Ken Konecki)
- Subject: Trouble with pragmas and vfork on Sparc
- Message-ID: <1992Jul30.163834.12312@sdc.com>
- Sender: news@sdc.com (Netnews administrator)
- Nntp-Posting-Host: grumpy
- Organization: Systems Development Corporation
- Distribution: na
- Date: Thu, 30 Jul 1992 16:38:34 GMT
- Lines: 95
-
- According to the man page for vfork:
- "On Sun-4 machines, ..., the file <vfork.h> must be included in
- programs that are compiled using global optimization."
-
- <vfork.h> contains the following:
- #ifdef sparc
- #pragma unknown_control_flow(vfork)
- #endif
-
- The compiler expects the parameter to unknown_control_flow to be an
- already existing symbol. The problem is that C++ doesn't add the extern
- until it finds a function that uses it, which is always after the pragma
- is parsed by the C compiler. Since vfork has not yet been added as a
- symbol, the C compiler spits out a warning to the tune of "function name
- expected"
-
- Here is some example C++ code (for example purposes only):
-
- #include <vfork.h>
-
- main(void)
- {
- if (vfork() == 0)
- {
-
-
- }
- }
-
- if you run CC -P on it you get (note the pragma *before* the extern int
- vfork):
- # 1 "post.c"
-
- /* <<AT&T C++ Translator 2.1.03 08/31/90>> */
- /* < post.c > */
-
- # 1 "post.c"
- char *__vec_new ();
-
- # 1 "post.c"
- char __vec_delete ();
- typedef int (*__vptp)();
- struct __mptr {short d; short i; __vptp f; };
-
- # 1 "post.c"
-
- # 107 "post.c"
- typedef char (*_PFV_ )();
- typedef int (*_PFI_ )();
-
- #pragma unknown_control_flow(vfork)
-
- # 129 "post.c"
- extern int vfork ();
- extern struct __mptr* __ptbl_vec__post_c_main_[];
-
- # 137 "post.c"
- int main (){ _main();
- # 138 "post.c"
- {
- # 139 "post.c"
- if (vfork ( ) == 0 )
- # 140 "post.c"
- {
- # 140 "post.c"
-
- # 143 "post.c"
- }
-
- # 144 "post.c"
- }
-
- # 144 "post.c"
- }
-
- /* this is to link in __head from libC.so for patch version of cfront */
- extern struct __linkl *__head;
- struct __linkl **__LinkInHead = (struct __linkl **)(& __head );
-
-
- # 145 "post.c"
-
- /* the end */
-
- Is this really a problem, i.e. is the pragma working the way it's expected
- to? If not, what recourse do I have, other than using fork() instead of
- vfork()?
-
- Cheers,
- -Ken K
- --
- Ken Konecki
- e-mail:kenk@sdc.com -or- ...!uunet!tellab5!sdc!kenk
- "I just found out that the brain is like a computer. If that's true,
- then there really aren't any stupid people. Just people running DOS."
-