码迷,mamicode.com
首页 > 其他好文 > 详细

VC 中关于UNREFERENCED_PARAMETER的使用

时间:2015-03-14 15:19:24      阅读:188      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!