USRP Hardware Driver and USRP Manual  Version: 4.6.0.0
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 #pragma once
9 
10 #include <uhd/config.hpp>
11 #include <iostream>
12 #include <stdexcept>
13 
21 #define UHD_SAFE_MAIN(_argc, _argv) \
22  _main(int, char*[]); \
23  int main(int argc, char* argv[]) \
24  { \
25  try { \
26  return _main(argc, argv); \
27  } catch (const std::exception& e) { \
28  std::cerr << "Error: " << e.what() << std::endl; \
29  } catch (...) { \
30  std::cerr << "Error: unknown exception" << std::endl; \
31  } \
32  return ~0; \
33  } \
34  int _main(_argc, _argv)