home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11819 < prev    next >
Encoding:
Text File  |  1992-07-30  |  2.4 KB  |  108 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!newsserver.pixel.kodak.com!laidbak!tellab5!sdc!kenk
  3. From: kenk@sdc.com (Ken Konecki)
  4. Subject: Trouble with pragmas and vfork on Sparc
  5. Message-ID: <1992Jul30.163834.12312@sdc.com>
  6. Sender: news@sdc.com (Netnews administrator)
  7. Nntp-Posting-Host: grumpy
  8. Organization: Systems Development Corporation
  9. Distribution: na
  10. Date: Thu, 30 Jul 1992 16:38:34 GMT
  11. Lines: 95
  12.  
  13. According to the man page for vfork:
  14.     "On Sun-4 machines, ...,  the  file  <vfork.h>  must  be included in
  15.     programs that are compiled using global optimization."
  16.  
  17. <vfork.h> contains the following:
  18.     #ifdef sparc
  19.     #pragma unknown_control_flow(vfork)
  20.     #endif
  21.  
  22. The compiler expects the parameter to unknown_control_flow to be an
  23. already existing symbol.  The problem is that C++ doesn't add the extern
  24. until it finds a function that uses it, which is always after the pragma
  25. is parsed by the C compiler.  Since vfork has not yet been added as a
  26. symbol, the C compiler spits out a warning to the tune of "function name
  27. expected"
  28.  
  29. Here is some example C++ code (for example purposes only):
  30.  
  31. #include <vfork.h>
  32.  
  33. main(void)
  34. {
  35.     if (vfork() == 0)
  36.     {
  37.     
  38.  
  39.     }
  40. }
  41.  
  42. if you run CC -P on it you get (note the pragma *before* the extern int
  43. vfork):
  44. # 1 "post.c"
  45.  
  46. /* <<AT&T C++ Translator 2.1.03 08/31/90>> */
  47. /* < post.c > */
  48.  
  49. # 1 "post.c"
  50. char *__vec_new ();
  51.  
  52. # 1 "post.c"
  53. char __vec_delete ();
  54. typedef int (*__vptp)();
  55. struct __mptr {short d; short i; __vptp f; };
  56.  
  57. # 1 "post.c"
  58.  
  59. # 107 "post.c"
  60. typedef char (*_PFV_ )();
  61. typedef int (*_PFI_ )();
  62.  
  63. #pragma unknown_control_flow(vfork)
  64.  
  65. # 129 "post.c"
  66. extern int vfork ();
  67. extern struct __mptr* __ptbl_vec__post_c_main_[];
  68.  
  69. # 137 "post.c"
  70. int main (){ _main(); 
  71. # 138 "post.c"
  72. # 139 "post.c"
  73. if (vfork ( ) == 0 )
  74. # 140 "post.c"
  75. # 140 "post.c"
  76.  
  77. # 143 "post.c"
  78. }
  79.  
  80. # 144 "post.c"
  81. }
  82.  
  83. # 144 "post.c"
  84.  
  85. /* this is to link in __head from libC.so for patch version of cfront */
  86. extern struct __linkl *__head;
  87. struct __linkl **__LinkInHead = (struct __linkl **)(& __head );
  88.  
  89.  
  90. # 145 "post.c"
  91.  
  92. /* the end */
  93.  
  94. Is this really a problem, i.e. is the pragma working the way it's expected
  95. to?  If not, what recourse do I have, other than using fork() instead of
  96. vfork()?
  97.  
  98. Cheers,
  99.     -Ken K
  100. -- 
  101. Ken Konecki
  102. e-mail:kenk@sdc.com    -or-    ...!uunet!tellab5!sdc!kenk
  103. "I just found out that the brain is like a computer.  If that's true,
  104. then there really aren't any stupid people.  Just people running DOS."
  105.