Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Announcement: using decltype for lazily loaded function

37 views
Skip to first unread message

Masatoshi Kimura

unread,
Feb 17, 2014, 5:35:32 PM2/17/14
to dev-pl...@lists.mozilla.org
Hello,

I recently changed a way to declare function pointers to be loaded
lazily on Windows.
Traditionally, we have to write a function prototype manually to declare
a function pointer. Example:

typedef int (WINAPI *tMessageBoxW)(HWND, LPCWSTR, LPCWSTR, UINT);
tMessageBoxW messageBoxW =
(tMessageBoxW) GetProcAddress(user32, "MessageBoxW");

This is boring and error prone.
However, the new C++ decltype can eliminate the hand-written prototypes:

decltype(MessageBoxW)* messageBoxW =
(decltype(MessageBoxW)*) GetProcAddress(user32, "MessageBoxW");

This keyword is available since MSVC 10. I decided to introduce it to
Mozilla tree because Mozilla doesn't build on MSVC 9 or earlier.
Please see bug 969918 for more details.

Reagrds,
Masatoshi Kimura
0 new messages