home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 21963 < prev    next >
Encoding:
Text File  |  1993-01-22  |  2.0 KB  |  56 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!gatech!europa.asd.contel.com!howland.reston.ans.net!spool.mu.edu!sgiblab!newsun!news
  3. From: Duane Murphy <damurphy@wc.novell.com>
  4. Subject: MPW VarArgs.h?
  5. Message-ID: <1993Jan22.164614.11185@novell.com>
  6. X-Xxdate: Fri, 22 Jan 93 16:53:41 GMT
  7. Sender: news@novell.com (The Netnews Manager)
  8. Nntp-Posting-Host: 130.57.72.123
  9. Organization: Novell, Inc.
  10. X-Useragent: Nuntius v1.1.1d12
  11. Date: Fri, 22 Jan 1993 16:46:14 GMT
  12. Lines: 42
  13.  
  14.  
  15. I am porting a program from the Unix world to the Macintosh.  At one 
  16. point we had everything working pretty well in Think C.  We also would 
  17. like to compile the program in MPW.  However, I have discovered that MPW 
  18. does not support the (outdated) varargs.h file.  I am using the MPW from 
  19. ETO 9 (C compiler 3.2.4).
  20.  
  21. Varags.h is (kind of) an older version of stdarg.h.  The varagrs 
  22. mechanism is used in many places in the code and I would rather not 
  23. change that (I would like to keep those code changes to a minimum).  I 
  24. looked at Think C's stdarg.h and varargs.h, compared them to MPW's 
  25. stdarg.h (which is slightly different) and I came up with this for 
  26. VarArgs.h for MPW.
  27.  
  28. #ifndef __VARARGS__
  29. #define __VARARGS__
  30.  
  31. #ifndef __va_list__
  32. #define __va_list__
  33. typedef char *va_list;
  34. #endif
  35.  
  36. #define va_dcl                int va_alist;
  37.  
  38. #define va_start(ap)         ap = (va_list) ((char *)&va_alist)
  39. #define va_arg(ap, type)     ((type *)(ap += sizeof (type)))[-1]
  40. #define va_end(ap)            /* do nothing */
  41.  
  42. #endif
  43.  
  44. Has any one else needed to do this?  Is this correct?  I am in the 
  45. processes of trying it right now.  This is one of those things that is 
  46. not easy to tell if this is going to work every time.
  47.  
  48. Thanks for any help,
  49. ...Duane
  50.  
  51.   +------------------------+--------------------------------------------+
  52.   | Duane Murphy           | My opinions are mine, mine, and only mine; |
  53.   | damurphy@wc.novell.com |      Except when they are also yours.      |
  54.   | Macintosh Software QA  |                                            |
  55.   +------------------------+--------------------------------------------+
  56.