Skip to content

Instantly share code, notes, and snippets.

@MLKrisJohnson
Last active June 21, 2017 15:15
Show Gist options
  • Save MLKrisJohnson/eb5e1cb623694372676c938be82c9bb4 to your computer and use it in GitHub Desktop.
Save MLKrisJohnson/eb5e1cb623694372676c938be82c9bb4 to your computer and use it in GitHub Desktop.
Objective-C++ program to decode an IOReturn/kern_return_t value
// Decodes an IOReturn/kern_return_t value.
// See https://developer.apple.com/library/content/qa/qa1075/_index.html for details
#include <iostream>
#include <iomanip>
#include <mach/error.h>
using std::cout;
using std::cerr;
using std::endl;
using std::hex;
using std::dec;
using std::stol;
using std::showbase;
int main(int argc, const char * argv[]) {
@autoreleasepool {
if (argc > 1) {
for (int i = 1; i < argc; ++i) {
auto err = stol(argv[1], 0, 0);
cout << showbase
<< hex << err
<< dec << "(" << err <<")"
<< hex
<< ": system=" << err_get_system(err)
<< "; subsystem=" << err_get_sub(err)
<< "; code=" << err_get_code(err)
<< endl;
}
}
else {
cerr << "usage: " << argv[0] << "CODE...";
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment