Avoiding FunctionA/W Duplication

Vincent Béron vberon at mecano.gme.usherb.ca
Tue Nov 5 12:42:15 CST 2002


Le mar 05/11/2002 à 13:33, Jaco Greeff a écrit :
> I would like some comments on somthing that has been bugging me quite a bit.
> Implementing parts of the API can lead to duplication of code inside the
> same file. In my example, let's take two functions, one operating on a ASCII
> string and one one a Unicode string, let's call them "funcA" and "funcW". 
> 
> Upon implementation, the only real difference between these are the
> parameters, "funcA(const char *p)" and "funcW(const WCHAR *p)". What is the
> best way to keep the code maintainable and making sure that we don't have to
> fix a single bug in two places in the same file? I see 3 (maybe more)
> approaches:
> 
> 1. Implement funcA, making funcW and exact copy with the relevant parameters
> and local variables changed;
> 
> 2. Implement a generic solution as a macro and get both funcA and funcW to
> call it will specific parameters;
> 
> 3. Do some preprosessor magic as implemented in dlls/msvcrt/scanf.[hc]
> 
> What is the general feeling as to the right way to approach this? What is
> the preferred approach? (And maybe it is something I haven't listed here.) 



More information about the wine-devel mailing list