Avoiding FunctionA/W Duplication

Dimitrie O. Paun dpaun at rogers.com
Tue Nov 5 18:24:21 CST 2002

On November 5, 2002 01:33 pm, Jaco Greeff wrote:

I know there has been answers, but here are my $0.02:

> 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]

These should be avoided as much as possible IMO. For too many reasons to 
list here. Option 4:
  4. Implement the meat in funcW, and make funcA a wrapper that just
     converts the arguments from A->W and back (if need be).
Is the most general. Sometimes there is Option 5:
  5. Implement the meat in a funcT that takes a boolean as an argument
     telling it if the input is A or W, and just have the func[AW]
     forward the call to funcT
This works only within one module, and there are other problems. That is,
if it does any non-trivial work with the string, that might require that
be converted between A<->W, it's better to go for 4, to avoid multiple
conversions (which are expensive).


More information about the wine-devel mailing list