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