首页 > 其他 > 详细

VC 中关于UNREFERENCED_PARAMETER的使用

时间:2015-03-14 15:16:41      阅读:167      评论:0      收藏:0      [点我收藏+]

使用vc10 时建C++的工程时,自动生成的入口函数如下:

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

     // TODO: Place code here.
    MSG msg;
    HACCEL hAccelTable;

    // Initialize global strings
    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadString(hInstance, IDC_S_WAR3HELPER, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance);

    // Perform application initialization:
    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_S_WAR3HELPER));

    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}

前中的前两行有 UNREFERENCED_PARAMETER

UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

这个宏在 winnt.h 中定义如下:

 

#define UNREFERENCED_PARAMETER(P) (P)

 

该宏的作用是展开传递的参数或表达式,其目的是避免编译器关于未引用参数的警告。

 

VC 中关于UNREFERENCED_PARAMETER的使用

原文:http://www.cnblogs.com/aqing1987/p/4337536.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!