|
From: Igor Mikolic-T. <ig...@al...> - 2002-09-11 03:00:17
|
Hi,
One really annoying problem with the w32api headers is that fairly common
identifiers like "DrawText", "SearchPath", "PostMessage", and
"ReportEvent" (to name only 4 of *many*) get hijacked by macros as result
of the way UNICODE is implemented. This often makes porting source code to
Windows an unnecessarily painful experience.
This problem can bite you even if your code only uses ISO standard headers,
because these often include w32api headers behind the scenes.
Please note that I am _not_ criticizing w32api -- this same problem exists
in the WinSDK headers -- it's all really Microsoft's fault ;).
I would like to solve this problem by replacing code like
#ifdef UNICODE
#define DrawText DrawTextW
#else
#define DrawText DrawTextA
#endif
with this:
#ifdef UNICODE
static __inline__ int DrawText(HDC h, LPCWSTR str, int count, LPRECT
rect, UINT format)
{
return DrawTextW(h, str, count, rect, format);
}
#else
static __inline__ int DrawText(HDC h, LPCSTR str, int count, LPRECT
rect, UINT format)
{
return DrawTextA(h, str, count, rect, format);
}
#endif
In C++ this means that your identifier named DrawText can co-exist happily
with the w32api function (unless the two happen to have the same calling
signature ;). In C, you get easy to understand errors about either (1)
wrong parameters passed to DrawText or (2) multiple definitions of
DrawText. A big improvement IMHO.
I've already done this for a bunch of cases that have already bitten me.
My question: is this something you would be interested in incorporating
into the w32api package?
If so, let me know. I'll make a concerted effort this weekend to fix a
whole bunch of these and submit a corresponding patch against the current
w32api 2.0 headers.
Igor
|