home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16717 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1.6 KB

  1. Path: sparky!uunet!usc!sol.ctr.columbia.edu!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Multiple Parameter Passing (unspecified number)
  5. Message-ID: <1992Nov18.113642.9801@thunder.mcrcim.mcgill.edu>
  6. Date: 18 Nov 92 11:36:42 GMT
  7. References: <92321.124834GNR100@psuvm.psu.edu> <1992Nov17.105837.21867@henson.cc.wwu.edu>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 26
  10.  
  11. In article <1992Nov17.105837.21867@henson.cc.wwu.edu>, n8743196@henson.cc.wwu.edu (Jeff Wandling) writes:
  12. > misar@rbg.informatik.th-darmstadt.de (walter misar) writes:
  13. >> In article <92321.124834GNR100@psuvm.psu.edu>, <GNR100@psuvm.psu.edu> writes:
  14.  
  15. >>> I'm looking to write a function that accepts any number of
  16. >>> paramerter.  [all varying params will be cbar *]
  17. >> [...]
  18. > I'm trying to do a similar thing, except my function doesn't know
  19. > what type to expect.  The next "variable argument" could be any
  20. > simple type.  How do I deal with this?
  21.  
  22. You don't.  Your function *must* be able to tell, somehow, the type of
  23. each argument; C simply does not give you any choice about this.  It
  24. doesn't matter how.  The example that started this thread knows that
  25. all its varargs arguments are char * a priori.  printf figures it out
  26. from the format string.  You could use global variables or anything
  27. else that'll get this information - but get it you must.
  28.  
  29. > Is there a way to switch on the type of the next argument?
  30.  
  31. No, that information is not available to the called function.
  32.  
  33.                     der Mouse
  34.  
  35.                 mouse@larry.mcrcim.mcgill.edu
  36.