gpt4 book ai didi

c++ - iOS const char* 到 std::string 并返回缺少第一个字符

转载 作者:行者123 更新时间:2023-11-29 05:32:37 37 4
gpt4 key购买 nike

我在 iOS 构建上的代码中遇到了一个特殊的运行时错误,其中 C++ 代码在 Xcode 10.3 的 iPhone 上运行。

在调试器中停止此代码:

const char* testChar = "testing";
std::string testingString = testChar;
const char* testCharBack = testChar.c_str();

const char* testCharBack 打印

"esting"

而不是

"testing"

enter image description here

编辑:NSLog 输出也缺少第一个字符:

NSLog( @"testingCharBack=%s", testCharBack );

2019-08-07 15:53:53.451173+0200 App[499:108370] testingCharBack=esting

我正在使用 libc++(支持 C++11 的 LLVN C++ 标准库)编译器和 c++11 方言。您知道构建或build设置可能有什么问题吗?

最佳答案

就我而言,结果是 __arm__ 预处理器宏导致应用程序失败并崩溃。

关于c++ - iOS const char* 到 std::string 并返回缺少第一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57394524/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com