home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / next / sysadmin / 4965 < prev    next >
Encoding:
Text File  |  1992-08-31  |  1.9 KB  |  61 lines

  1. Xref: sparky comp.sys.next.sysadmin:4965 comp.sys.next.programmer:5905
  2. Newsgroups: comp.sys.next.sysadmin,comp.sys.next.programmer
  3. Path: sparky!uunet!decwrl!csus.edu!news
  4. From: eps@futon.SFSU.EDU (Eric P. Scott)
  5. Subject: Re: NNTP Compiling - type mismatch in initialization
  6. Message-ID: <1992Sep1.102639.22689@csus.edu>
  7. Followup-To: comp.sys.next.programmer
  8. Sender: news@csus.edu
  9. Reply-To: eps@cs.sfsu.edu
  10. Organization: San Francisco State University
  11. References: <1992Aug31.152659.15528@magnus.acs.ohio-state.edu>
  12. Date: Tue, 1 Sep 1992 10:26:39 GMT
  13. Lines: 46
  14.  
  15. [comp.sys.next.sysadmin is an inappropriate newsgroup for this
  16.  question; followups have been redirected to
  17.  comp.sys.next.programmer]
  18.  
  19. In article <1992Aug31.152659.15528@magnus.acs.ohio-state.edu>
  20.     szatezal@magnus.acs.ohio-state.edu (Shane M Zatezalo)
  21.     writes:
  22. >I'm trying to compile NNTP, and when the compiler is doing the file "misc.c"
  23. >it bombs out with this:
  24.  
  25. >misc.c:955: type mismatch in initialization
  26.  
  27. >struct  nlist Nl[] =
  28. >{
  29. >        { "_avenrun" },
  30.  
  31. (1) You need to add another layer of braces to nlist vectors
  32. before they'll compile, e.g.
  33.     { { "_avenrun" } },
  34. [I suggest using  #if[n]def NeXT  conditionals as warranted]
  35.  
  36. (2) Mining load average out of kmem is the WRONG approach on the
  37. NeXT.  A better way is to use the table() call, which also
  38. doesn't require exceptional access privileges.  This example
  39. ought to be in the programmers' FAQ; the question seems to come
  40. up about every other month.
  41.  
  42. #include <stdio.h>
  43. #include <sys/types.h>
  44. #include <sys/table.h>
  45. main() {
  46.     struct tbl_loadavg avg;
  47.  
  48.     (void)table(TBL_LOADAVG, 0, (caddr_t)&avg, 1, sizeof avg);
  49.     (void)printf("load average:%5.2f,%5.2f,%5.2f\n",
  50.         (double)avg.tl_avenrun[0]/(double)avg.tl_lscale,
  51.         (double)avg.tl_avenrun[1]/(double)avg.tl_lscale,
  52.         (double)avg.tl_avenrun[2]/(double)avg.tl_lscale);
  53.     exit(0);
  54. }
  55.  
  56. Valid for 1.0
  57. Valid for 2.0
  58. Not verified for 3.0
  59.  
  60.                     -=EPS=-
  61.