Home > Archive > Smartphone Developer Forum > January 2006 > More reliance on undocumented behaviour
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
More reliance on undocumented behaviour
|
|
| Norman Diamond 2006-01-19, 9:58 pm |
| I created an eVC++4 project TestSDK as instructed by the Readme file in the
Smartphone 2003 SDK. The TestSDK project includes the following code,
straight from Microsoft:
// Pump messages until a PostQuitMessage.
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage(&msg);
}
MSDN page
http://msdn.microsoft.com/library/d...fGetMessage.asp
reminds us that in eMbedded Visual C++ 4, just like in desktop Visual C++,
the value of a BOOL can be TRUE, FALSE, or OTHER. It says approximately:
> Return Values
> Nonzero indicates that the function retrieves a message other than
> WM_QUIT. Zero indicates that the function retrieves the WM_QUIT message,
> or that lpMsg is an invalid pointer. ?1 indicates that an error occurred
[...]
> Remarks
[...]
> Note that the function return value can be nonzero, zero, or ?1. Thus, you
> should avoid code like this.
> while (GetMessage( lpMsg, hWnd, 0, 0)) ...
> The possibility of a ?1 return value means that such code can lead to
> fatal application errors.
(The page actually has something that looks like "-1" instead of question
marks, but Outlook Express doesn't want to copy it unless I post in Unicode.
I have a feeling that copying and pasting from MSDN to the eMbedded Visual
C++ window might also yield undesirable results.)
Anyway, MSDN explicitly prohibits Microsoft's SDK example programmer (and
readers of the example) from coding the GetMessage loop that way.
So why did Microsoft rely on undocumented behaviour? And more importantly,
should other programmers rely on the example?
Some famous Microsoft programmers hate companies that rely on undocumented
behaviour.
| |
|
| Norman Diamond wrote:
>
>
> Anyway, MSDN explicitly prohibits Microsoft's SDK example programmer (and
> readers of the example) from coding the GetMessage loop that way.
>
> So why did Microsoft rely on undocumented behaviour? And more importantly,
> should other programmers rely on the example?
In this case you should follow the docs, that loop was written bady and
could break in future. It's just a little easier to read, and happens to
work as is.
riki
"Dave. Put down those Windows disks, Dave. DAVE!"
ThemeChanger for Smartphone : http://homepages.inspire.net.nz/~gambit/
AbstractStart for Smartphone :
http://homepages.inspire.net.nz/~gambit/AbstractStart/
Latest Betas have WM5 layout and speed dial support
|
|
|
|
|