In gcc 4.2, questo funziona:Xcode/LLVM clausola catch non soddisfano tipi derivati
#include <stdexcept>
#include <iostream>
int main() {
try {
throw std::runtime_error("abc");
} catch (const std::exception& ex) {
std::cout << ex.what();
}
}
In Xcode 4.3.2 (IOS con LLVM 3.1, -std = C++ 11), questo non riesce con terminate called throwing an exception
, senza mai raggiungere la linea 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);
}
Ma questo funziona:
#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);
}
Che cosa dà?
togliere la 'const' e dicci cosa ottieni –
@MarkRansom: nessuna modifica. Ho provato a '... catch (std :: exception ex) ...' di nuovo, nessun cambiamento. –