boostorg / interprocess

Boost.org interprocess module
http://boost.org/libs/interprocess
132 stars 117 forks source link

How to disable exceptions in boost interprocess? #179

Closed prncoprs closed 2 years ago

prncoprs commented 2 years ago

I want to disable the exceptions in my program.

I defined BOOST_EXCEPTION_DISABLE and BOOST_NO_EXCEPTIONS. Then I included the boost::interprocess related head files in my program. And I use gcc -o example example1.cpp -fno-exceptions to compile my program.

However, the compilation logs said just as follows.

In file included from /usr/include/boost/interprocess/detail/managed_memory_impl.hpp:29,
                 from /usr/include/boost/interprocess/managed_shared_memory.hpp:25,
                 from example1.cpp:5:
/usr/include/boost/interprocess/exceptions.hpp: In constructor ‘boost::interprocess::interprocess_exception::interprocess_exception(const char*)’:
/usr/include/boost/interprocess/exceptions.hpp:43:14: error: exception handling disabled, use ‘-fexceptions’ to enable
   43 |       catch (...) {}
      |              ^~~

So, does this mean that I had failed to disabled the exceptions in my program? Can someone help me with it, so that I can use boost::interprocess and -fno-exceptions together?

Thanks very much!

igaztanaga commented 2 years ago

I'm sorry to tell you that Boost.Interprocess does not support builds with disabled exceptions. Supporting exception-less builds would requiere a redesign of many interfaces because many functions and classes...