c – Xcode / LLVM catch子句与派生类型不匹配
发布时间:2020-12-14 19:13:46 所属栏目:百科 来源:网络整理
导读:在 gcc 4.2中,这有效: #include stdexcept#include iostreamint main() { try { throw std::runtime_error("abc"); } catch (const std::exception ex) { std::cout ex.what(); }} 在Xcode 4.3.2(带有LLVM 3.1的iOS,-std = c 11)中,这会因为终止而失败,称为
在
gcc 4.2中,这有效:
#include <stdexcept> #include <iostream> int main() { try { throw std::runtime_error("abc"); } catch (const std::exception& ex) { std::cout << ex.what(); } } 在Xcode 4.3.2(带有LLVM 3.1的iOS,-std = c 11)中,这会因为终止而失败,称为抛出异常,从未到达NSLog(…)行: #include <stdexcept> int main() { try { throw std::runtime_error("abc"); } catch (const std::exception& ex) { NSLog(@"%s",ex.what()); } return UIApplicationMain(argc,argv,nil,nil); } 但这有效: #include <stdexcept> int main() { try { throw std::runtime_error("abc"); } catch (const std::runtime_error& ex) { NSLog(@"%s",nil); } 是什么赋予了? 解决方法
gcc是正确的:
这听起来像是一个xcode bug(而且是一个令人惊讶的基本错误!) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容