USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
safe_main.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_UTILS_SAFE_MAIN_HPP
8 #define INCLUDED_UHD_UTILS_SAFE_MAIN_HPP
9 
10 #include <uhd/config.hpp>
11 #include <iostream>
12 #include <stdexcept>
13 
21 #define UHD_SAFE_MAIN(_argc, _argv) _main(int, char*[]); \
22 int main(int argc, char *argv[]){ \
23  try { \
24  return _main(argc, argv); \
25  } catch(const std::exception &e) { \
26  std::cerr << "Error: " << e.what() << std::endl; \
27  } catch(...) { \
28  std::cerr << "Error: unknown exception" << std::endl; \
29  } \
30  return ~0; \
31 } int _main(_argc, _argv)
32 
33 #endif /* INCLUDED_UHD_UTILS_SAFE_MAIN_HPP */