[英]What is the meaning of CDECL in this code?
在这里,我有一个来自编程 windows 第五版的代码。
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, ...)
{
TCHAR szBuffer[1024];
va_list pArgList;
// The va_start macro (defined in STDARG.H) is usually equivalent to:
// pArgList = (char *) &szFormat + sizeof (szFormat) ;
va_start(pArgList, szFormat);
// The last argument to wvsprintf points to the arguments
_vsntprintf(szBuffer, sizeof (szBuffer) / sizeof (TCHAR),
szFormat, pArgList);
// The va_end macro just zeroes out pArgList for no good reason
va_end(pArgList);
return MessageBox(NULL, szBuffer, szCaption, 0);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
int cxScreen, cyScreen;
cxScreen = GetSystemMetrics(SM_CXSCREEN);
cyScreen = GetSystemMetrics(SM_CYSCREEN);
MessageBoxPrintf(TEXT("ScrnSize"),
TEXT("The screen is %i pixels wide by %i pixels high."),
cxScreen, cyScreen);
return 0;
}
下面代码中 int 之后的 CDECL 是什么意思?
int CDECL MessageBoxPrintf(TCHAR * szCaption, TCHAR * szFormat, ...)
在 windows 头文件中, CDECL
是这样定义的:
#define CDECL
这似乎有点奇怪。 这是一个扩展为空的宏。 在需要调用约定的地方使用它会导致默认调用约定,即__cdecl
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.