Go to main content
Oracle® Developer Studio 12.6: C++ User's Guide

Exit Print View

Updated: July 2017

8.7 Mixing C and C++ Code

When compiling in -compat=5 mode, C and C++ code can be freely mixed. Exceptions will pass through any C functions that may be on the stack between the point where the exception is thrown and the point where it is caught.

When compiling in gcc compatibility mode, exceptions might not propagate through C stack frames for any of these options: -std=c++03, -std=c++11, -std=c++14, or -compat=g. Code compiled by the C compiler needs to be compiled with the option –fexceptions to ensure proper exception handling. The same is true when using GNU C and C++ compilers.