5

Is it possible to throw an exception from a plain C function to be caught by a C++ function using gcc in x86 (and possibly x86-64) Linux?

What about catching a C++ exception in C code?

I'm hoping there's a way since the exception frame information is already there.

Note 1: I don't care about compatibility. A gcc only hack (internal function calls, language extension etc.) will do just fine.

Note 2: I can't compile the plain C part of the application with g++ for several reasons.

cyco130
  • 4,654
  • 25
  • 34
  • 2
    I would start by looking at the assembly generated by attempting to catch the exception in C++, and perhaps port over what you find using inline assembly. – Richard J. Ross III Apr 03 '14 at 09:16
  • 1
    You could publish a function `throw_exception()` from your C++ code, and call that from the C – M.M Apr 03 '14 at 09:24
  • I _don't_ think it's a duplicate. I thought it was clear that what I wanted was a kind of interoperability between C and C++ exceptions. – cyco130 Apr 03 '14 at 12:40

0 Answers0