En gcc 4.2, esto funciona:Xcode/LLVM cláusula catch que no coincida con los tipos derivados
#include <stdexcept>
#include <iostream>
int main() {
try {
throw std::runtime_error("abc");
} catch (const std::exception& ex) {
std::cout << ex.what();
}
}
En Xcode 4.3.2 (iOS con LLVM 3.1, -std = C++ 11), esta falla con terminate called throwing an exception
, sin llegar nunca a la línea 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);
}
Pero esto funciona:
#include <stdexcept>
int main() {
try {
throw std::runtime_error("abc");
} catch (const std::runtime_error& ex) {
NSLog(@"%s", ex.what());
}
return UIApplicationMain(argc, argv, nil, nil);
}
lo que da?
sacar la 'const' y dinos lo que obtienes. –
@MarkRansom: Sin cambios. Intenté '... catch (std :: exception ex) ...' también; de nuevo, sin cambios. –