home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18343 < prev    next >
Encoding:
Text File  |  1992-12-14  |  1.7 KB  |  54 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!cs.uiuc.edu!vela!pd-dom!agrafiot
  3. From: agrafiot@wl.com (Dimitris Agrafiotis)
  4. Subject: Re: questions on variable argument lists
  5. Message-ID: <1992Dec14.203422.5537@wl.com>
  6. Sender: agrafiot@wl.com
  7. Organization: Warner Lambert / Parke-Davis
  8. References: <1992Dec14.195419.4785@wl.com>
  9. Distribution: usa
  10. Date: Mon, 14 Dec 1992 20:34:22 GMT
  11. Lines: 41
  12.  
  13. In article <1992Dec14.195419.4785@wl.com> agrafiot@wl.com (Dimitris Agrafiotis) writes:
  14. >
  15. >I want to define a function, alpha(), that takes as arguments a pointer to a
  16. >function, beta(), and the arguments to be passed to that function. Ideally,
  17. >the function would be implemented as follows:
  18. >
  19. >void alpha(void (*beta)(...), ...)
  20. >{
  21. >   va_list arg;
  22. >   va_start(arg, beta);
  23. >   (*beta)(arg);
  24. >   va_end(arg);
  25. >}
  26. >
  27. >but that doesn't work for several reasons. First, the compiler seems to
  28. >require at least one argument in the declaration of beta(). Is there
  29. >an elegant way around that ? Second, even when you avoid this problem
  30. >by introducing a dummy argument, you get garbage at run time (this was
  31. >run on an SGI Indigo). What is the reason? What's the best alternative
  32. >and how portable would it be?
  33. >Thanks in advance,
  34. >
  35. >-- 
  36. >Dimitris K. Agrafiotis
  37. >Computer Assisted Drug Design
  38. >Parke-Davis Pharmaceutical Research
  39. >(agrafiot@wl.com)
  40.  
  41. I did some experiments and I think I found the solution to my problem
  42. (at least on the SGI machines). The declaration would be something like:
  43.  
  44. void alpha(void (*beta)(va_list arg), ...);
  45.  
  46. and the rest is obvious. Sorry for waisting your time.
  47.  
  48.  
  49. -- 
  50. Dimitris K. Agrafiotis
  51. Computer Assisted Drug Design
  52. Parke-Davis Pharmaceutical Research
  53. (agrafiot@wl.com)
  54.