[vox-tech] overloading in C
Brian Lavender
brian at brie.com
Thu Feb 11 00:23:38 PST 2010
On Wed, Feb 10, 2010 at 10:58:48PM -0800, Bill Kendrick wrote:
> On Wed, Feb 10, 2010 at 10:10:31PM -0800, Brian Lavender wrote:
> > I guess in C, you can't overload a function?
> <snip>
>
> You could use "...", like prinf() and scanf() use. ;)
>
This seemed to do the trick.
> What I end up doing (and have seen other C-based APIs do) is
> something like this:
>
> void oldfunction(type1 arg1)
> { ...some code... }
>
> oops, I need two args! Rewrite time!
>
> void newfunction(type1 arg1, type2 arg2)
> { ...some code... }
>
> void oldfunction(type1 arg1)
> {
> newfunction(arg1, somedefault);
> }
>
>
> So now, anything that used oldfunction() still works as-is
> (API didn't change), but if I need the additional arguments,
> I can call the newer function (which really started life as
> a rename of the old function, then had some code added to it).
--
Brian Lavender
http://www.brie.com/brian/
"Too much hype, too much confusion, and too many people talking about
something they don't understand have greatly muddied the waters in the
last year or so."
Borland Turbo Pascal OO Programming Guide
1989
More information about the vox-tech
mailing list