- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 10 月 2 日发布的 Symbian S60 第 5 版 SDK,我正在编译/运行(在 sim 上)以下代码片段:
void test(wchar_t *dest, int size, const wchar_t *fmt, ...) {
va_list vl;
va_start(vl, fmt);
vswprintf(dest, size, fmt, vl);
va_end(vl);
}
...
wchar_t str[1024];
// this crashes (2nd string 123 characters (+ \0) equals 248 bytes)
test(str, 1024, L"msg: %S", L"this is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a tes");
// this works (2nd string 122 characters (+ \0) equals 246 bytes)
test(str, 1024, L"msg: %S", L"this is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a test messagethis is a te");
对于我来说没有明显的原因(即使在阅读了 vswprintf 手册页一百次之后)我能弄清楚为什么这段代码在 vswprintf 调用长字符串时崩溃了 :-( 完全相同的代码有效在 Linux 机器上很好。为 str 分配了足够的内存,而且 vswprintf 正在检查缓冲区是否溢出。不幸的是,... S60 调试器在这次崩溃时没有中断,所以我没有详细信息:-(
有人有什么想法吗?
假设 Symbian 的 vswprintf 例程中存在错误,使用 POSIX 兼容代码的可能替换函数是什么? (这应该是一个跨平台的库)
谢谢。
最佳答案
对我来说,这看起来像是进入 vswprintf()
调用的工作。即使您只能进行汇编级调试,也应该通过监视 str[]
内存中发生的事情,或多或少地清楚发生了什么。
关于c++ - vswprintf 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/213875/
使用 10 月 2 日发布的 Symbian S60 第 5 版 SDK,我正在编译/运行(在 sim 上)以下代码片段: void test(wchar_t *dest, int size, con
我仍然是 C 的新手,甚至对 C 中的宽字符更陌生。 下面的代码应该显示 蓝 Sprite 4分 但它显示 蓝 Sprite 4分 在 gdb 中,我看到这个: (gdb) p buffer $1 =
有谁知道什么时候可以使用 vswprintf_l 而不是 vswprintf ? 谢谢 最佳答案 不同之处在于,vswprintf_l 在末尾添加一个 locale_t 类型的额外参数。这意味着您可以
我有以下示例程序,它使用预处理器定义一个简单的调试函数。 main.c #include #ifdef DEBUG #define __DEBUG 1 #else #define __DEBUG 0
我正在尝试使用 MinGW 在 Windows 上编译 Botan,但在编译期间收到以下错误: c:\qt\2010.04\mingw\bin\../lib/gcc/mingw32/4.4.0/inc
我有一个使用 _vscwprintf()/vswprintf() 的项目(通过 _vsctprintf()/_vstprintf()) 在 malloc()ed 缓冲区中创建任意长度的格式化字符串。
到目前为止,我已经在 visual studio 中编写了所有代码,现在我需要向其中添加一些 UI,因此我将使用 Qt。所以我在我的项目中添加了每个文件(主类除外),然后尝试使用 Qt 编译它。因为我
使用 Borland C++ Builder 2009 我根据 RAD Studio 的帮助 (F1) 使用 vswprintf : int vswprintf(wchar_t *buffer, co
为了提供更多细节,我正在使用 XCode 4.2 和 LLVM GCC 4.2.2 编译器使用 C 为 OS X 编写代码。 我有一个可变参数函数 - 为了完整起见,我包含了整个函数,尽管我/相信/其
我需要为格式函数 vswprintf() 分配足够的缓冲区。当用 ANSI 字符串做同样的事情时,我使用: vsnprintf( NULL, NULL, pszFormat, args ); 它返回我
我从 vswprintf 使用 GCC 和 Mac OS X(在 Mac OS X 10.6 和 10.8 下使用 gcc 4.0 和 4.2.1 测试。Linux 下的 GCC 是不受影响。Visu
我需要实现一个函数来格式化宽字符字符串并返回 std::wstring。我的实现是: std::wstring format(const wchar_t* fmt, ...) { std::w
我是一名优秀的程序员,十分优秀!