我正在尝试将 RtlStringCbPrintf 与 Winsock 内核一起使用。我包含了 Ntstrsafe.h 但编译器给我错误
Error 4 error C3861: 'RtlStringCbPrintf': identifier not found c:\bw\epic_sl\musslcomm\musslcomm\commmessenger\socketx.h 124 1 CommMessenger
如果我使用 RtlStringCbPrintfA 或 RtlStringCbPrintfW 那么它会编译。为什么我不能使用通用版本?在 Ntstrsafe.h 中,我看到了 RtlStringCbPrintfA 和 RtlStringCbPrintfW 的原型(prototype)声明,但没有 RtlStringCbPrintf 的声明,尽管注释引用了它。为什么我不能使用通用形式以便我的字符集属性选择要使用的版本?我的字符集属性设置为使用多字节字符集
最佳答案
因为windows没有为这两个函数提供RtlStringCbPrintf定义。来自 msdn:
Use RtlStringCbPrintfW to handle Unicode strings and RtlStringCbPrintfA to handle ANSI strings. The form you use depends on your data..
msdn 中的示例使用 RtlStringCbPrintfW() 函数,而不是 RtlStringCbPrintf()。
你可以自己定义 RtlStringCbPrintf():
#if defined(UNICODE)
# define RtlStringCbPrintf RtlStringCbPrintfA
#else
# define RtlStringCbPrintf RtlStringCbPrintfW
#endif
关于c++ - 如前所述,RtlStringCbPrintf 不在 ntstrsafe.h 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25043348/