Is there any way, short of putting an attribute on each function prototype, to let gcc know that C functions can never propagate exceptions, i.e. that all functions declared ins
Side note:
Are you sure telling the compiler "all these funcs never throw" is exactly what you want ?
It's not necessarily so that extern "C" ...
functions cannot propagate/trigger exceptions. Take a case in point:
class Foo {
public:
class Away {};
static void throwaway(void) { throw Away(); }
}
extern "C" {
void wrap_a_call(void (*wrapped)(void)) { wrapped(); }
}
int main(int argc, char **argv)
{
wrap_a_call(Foo::throwaway);
return 0;
}
Compiling and running this creates a C-linkage function wrap_a_call()
which, when called like above, will happily cause an exception:
$ ./test
terminate called after throwing an instance of 'Foo::Away'
Abort(coredump)
I.e. there can be "exception leakage" with extern "C"
(through invoking function pointers) and just because you're using/invoking extern "C"
functions in a particular place in C++ doesn't guarantee no exceptions can be thrown when invoking those.