Winefile: fix "move file" implementation

Martin Fuchs martin-fuchs at
Thu Oct 7 02:02:18 CDT 2004

> > Come on - is this really that difficult?  ;-)
> > And as you see, I will maintain it for you.

> The problem is not whether you are maintaining it or not.

Well, you began to talk about maintaining the code:

>> By using TCHAR you actually hide the problem and make the code
>> very hard to maintain. What is the purpose of that in Wine or
>> ReactOS? Why don't you use unicode directly?

> It's about a programming practices in Wine for internal
> Win32 code. Using TCHAR buys you nothing. That's not you
> really want to maintain. Why do you need to hide real API
> names and types?

My programming practice is to use TCHAR and the appropriate
function names to get a code that can simple be compiled in
both modes. And it's really not difficult. You only have to use
some rules.

For example:
- Use buffers on the stack to avoid malloc() calls for string
  buffers:  TCHAR buffer[BUFFER_LEN];
- If you need to use dynamic allocation, just do:
  LPTSTR buffer = (LPTSTR) malloc(len*sizeof(TCHAR));
- Use _tcs... functions or lstr... functions instead of str...
  functions: _tcslen() or lstrlen() instead of strlen()

Or just use C++ instead of C, then you can hide the internals
more easily in a String class.

Using this simple rules you get a program you can use in
both versions. Of course if you know, you will only use your
program in the UNICODE version, this doesn't make sense.
In this case just program it using WCHAR strings.

> That approach leads you for instance to the following buggy
> code: reactos/lib/user32/windows/messagebox.c. A developer
> who has ported Wine code simply does not see a difference
> between A and W kind of APIs and types and uses type casts
> to hide compiler warnings. That code is terribly broken, but
> it's very hard to find.

Then this is the problem of that developer. He should not use
type casts at wrog places to hide compiler warnings.

AJ> Maybe we should forbid TCHARs in the programs/ directory too...

Do what you can't let.

It's just not the same if you code an application, which could
be used in both modes (UNICODE/ANSI), or if you code some
internal Wine DLL. Using TCHARs there doesn't make sence,

Let's finish this discussion here. I see it does not lead to some
usefull end.


More information about the wine-devel mailing list