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