WIndows System Programming use of standard C library
本问题已经有最佳答案,请猛点这里访问。
我正在阅读Johnson M. Hart Windows系统编程。 他有一个使用va_start标准c方法的方法。 在下面的示例中,有人可以解释为什么将Handle hOut传递给va_start吗?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | BOOL PrintStrings (HANDLE hOut, ...) /* Write the messages to the output handle. Frequently hOut will be standard out or error, but this is not required. Use WriteConsole (to handle Unicode) first, as the output will normally be the console. If that fails, use WriteFile. hOut: Handle for output file. ... : Variable argument list containing TCHAR strings. The list must be terminated with NULL. */ { DWORD msgLen, count; LPCTSTR pMsg; va_list pMsgList; /* Current message string. */ va_start (pMsgList, hOut); /* Start processing msgs. */ while ((pMsg = va_arg (pMsgList, LPCTSTR)) != NULL) { msgLen = lstrlen (pMsg); if (!WriteConsole (hOut, pMsg, msgLen, &count, NULL) && !WriteFile (hOut, pMsg, msgLen * sizeof (TCHAR), &count, NULL)) { va_end (pMsgList); return FALSE; } } va_end (pMsgList); return TRUE; } |
有关可变参数通常如何实现的一些详细信息:
- 如何在gcc中实现变量参数?
-