C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
catchiofailure.cpp
Go to the documentation of this file.
1 #define _GLIBCXX_USE_CXX11_ABI 0
2 // include libstdc++ specific header <bits/c++config.h> containing __GLIBCXX__
3 // without including ios already (must be included after setting _GLIBCXX_USE_CXX11_ABI)
4 #include <cstddef>
5 
6 // ensure the old ABI is used under libstd++ < 7 and the new ABI under libstd++ >= 7
7 // (because libstdc++ < 7 throws the old ios_base::failure and libstdc++ >= 7 the new one)
8 #if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 7
9 #undef _GLIBCXX_USE_CXX11_ABI
10 #define _GLIBCXX_USE_CXX11_ABI 1
11 #endif
12 
13 #include "./catchiofailure.h"
14 
15 #include <ios>
16 
17 using namespace std;
18 
19 namespace IoUtilities {
20 
36 const char *catchIoFailure()
37 {
38  try {
39  throw;
40  } catch (const ios_base::failure &e) {
41  return e.what();
42  }
43 }
44 
49 void throwIoFailure(const char *what)
50 {
51  throw ios_base::failure(what);
52 }
53 } // namespace IoUtilities
CPP_UTILITIES_EXPORT void throwIoFailure(const char *what)
Throws an std::ios_base::failure with the specified message.
Contains utility classes helping to read and write streams.
Definition: binaryreader.h:10
CPP_UTILITIES_EXPORT const char * catchIoFailure()
Provides a workaround for GCC Bug 66145.