Opened 13 years ago
Closed 13 years ago
#3335 closed Feature Requests (duplicate)
boost::threads does not compile with gcc -fno-exceptions
Reported by: | Owned by: | Anthony Williams | |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | thread |
Version: | Boost 1.39.0 | Severity: | Not Applicable |
Keywords: | Cc: | nigels@… |
Description
The following program fails to compile:
--snip #define BOOST_NO_EXCEPTIONS
#include <boost/thread/mutex.hpp>
int foo;
int fn(boost::mutex& pMutex) {
boost::mutex::scoped_lock lock(pMutex); return foo;
}
--snip
It fails:
# g++ -fno-exceptions -I/home/andyc/work/3rdParty/boost_1_39_0 -c -o test.o test.cpp In file included from /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/mutex.hpp:16,
from test.cpp:3:
/home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/mutex.hpp: In constructor ?boost::mutex::mutex()?: /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/mutex.hpp:40: error: exception handling disabled, use -fexceptions to enable
There are other exceptions in boost/thread/locks.hpp that aren't surrounded by #ifndef BOOST_NO_EXCEPTIONS too. I've attached a patch to fix those.
Attachments (3)
Change History (7)
by , 13 years ago
Attachment: | locks.hpp.patch added |
---|
by , 13 years ago
Attachment: | mutex.hpp.patch added |
---|
patch to boost/thread/pthread/mutex.hpp to make it BOOST_NO_EXCEPTIONS aware.
comment:1 by , 13 years ago
Component: | None → thread |
---|---|
Owner: | set to |
comment:2 by , 13 years ago
using once.hpp also fails to compile:
<pre> --snip #define BOOST_NO_EXCEPTIONS
#include <boost/thread/once.hpp>
boost::once_flag once = BOOST_ONCE_INIT;
bool initialised = false;
void testOnceInit() {
assert(!initialised); initialised = true;
}
struct ConstructOnce {
ConstructOnce() {
boost::call_once(&testOnceInit, once);
}
};
ConstructOnce first; ConstructOnce second;
--snip # g++ -Wall -fno-exceptions -I/home/andyc/work/3rdParty/boost_1_39_0 -c -o testonce.o testonce.cpp /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/once.hpp: In function ?void boost::call_once(boost::once_flag&, Function) [with Function = void (*)()]?: /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/once.hpp:27: instantiated from here /home/andyc/work/3rdParty/boost_1_39_0/boost/thread/pthread/once.hpp:66: error: exception handling disabled, use -fexceptions to enable </pre>
by , 13 years ago
Attachment: | once.hpp.patch added |
---|
patch to boost/thread/pthread/once.hpp to make it BOOST_NO_EXCEPTIONS aware.
comment:3 by , 13 years ago
Severity: | Problem → Not Applicable |
---|---|
Type: | Bugs → Feature Requests |
Your patches just protect the throw statements, but what would be the behavior of the application with your patches. I think Boost.Threads has not an interface that allows to use it without exceptions, so I will consider this a feature request and not a Bug.
comment:4 by , 13 years ago
Cc: | added |
---|---|
Milestone: | Boost 1.40.0 → Boost 1.43.0 |
Resolution: | → duplicate |
Status: | new → closed |
Marking this as a duplicate of #2100 - thread fails to compile with -fno-exceptions.
The good news is that this is just about resolved in boost svn trunk.
patch to boost/thread/locks.hpp to make it BOOST_NO_EXCEPTIONS aware.