<bdo id='B7CzO'></bdo><ul id='B7CzO'></ul>

    1. <small id='B7CzO'></small><noframes id='B7CzO'>

        <tfoot id='B7CzO'></tfoot>
      1. <legend id='B7CzO'><style id='B7CzO'><dir id='B7CzO'><q id='B7CzO'></q></dir></style></legend>
        <i id='B7CzO'><tr id='B7CzO'><dt id='B7CzO'><q id='B7CzO'><span id='B7CzO'><b id='B7CzO'><form id='B7CzO'><ins id='B7CzO'></ins><ul id='B7CzO'></ul><sub id='B7CzO'></sub></form><legend id='B7CzO'></legend><bdo id='B7CzO'><pre id='B7CzO'><center id='B7CzO'></center></pre></bdo></b><th id='B7CzO'></th></span></q></dt></tr></i><div id='B7CzO'><tfoot id='B7CzO'></tfoot><dl id='B7CzO'><fieldset id='B7CzO'></fieldset></dl></div>

        C++ 异常会安全地通过 C 代码传播吗?

        Will C++ exceptions safely propagate through C code?(C++ 异常会安全地通过 C 代码传播吗?)

          <small id='Wfskd'></small><noframes id='Wfskd'>

            <tbody id='Wfskd'></tbody>

            <legend id='Wfskd'><style id='Wfskd'><dir id='Wfskd'><q id='Wfskd'></q></dir></style></legend>
            • <bdo id='Wfskd'></bdo><ul id='Wfskd'></ul>

                <tfoot id='Wfskd'></tfoot>
                <i id='Wfskd'><tr id='Wfskd'><dt id='Wfskd'><q id='Wfskd'><span id='Wfskd'><b id='Wfskd'><form id='Wfskd'><ins id='Wfskd'></ins><ul id='Wfskd'></ul><sub id='Wfskd'></sub></form><legend id='Wfskd'></legend><bdo id='Wfskd'><pre id='Wfskd'><center id='Wfskd'></center></pre></bdo></b><th id='Wfskd'></th></span></q></dt></tr></i><div id='Wfskd'><tfoot id='Wfskd'></tfoot><dl id='Wfskd'><fieldset id='Wfskd'></fieldset></dl></div>
                  本文介绍了C++ 异常会安全地通过 C 代码传播吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个调用 SQLite 的 C++ 应用程序(SQLite 在 C 中)sqlite3_exec() 反过来可以调用我用 C++ 实现的回调函数.SQLite 被编译成静态库.

                  I have a C++ application that calls SQLite's (SQLite is in C) sqlite3_exec() which in turn can call my callback function implemented in C++. SQLite is compiled into a static library.

                  如果异常逃脱了我的回调,它是否会通过 SQLite 的 C 代码安全地传播到调用 sqlite3_exec() 的 C++ 代码?

                  If an exception escapes my callback will it propagate safely through the C code of SQLite to the C++ code calling sqlite3_exec()?

                  推荐答案

                  我猜这是编译器依赖的.但是,在回调中抛出异常将是一个非常糟糕的主意.要么它完全不起作用,要么 SQLite 库中的 C 代码将无法处理它.考虑一下这是否是 SQLite 中的一些代码:

                  My guess is that this is compiler dependent. However, throwing an exception in the callback would be a very bad idea. Either it will flat-out not work, or the C code in the SQLite library will be unable to handle it. Consider if this is some code in SQLite:

                  {
                    char * p = malloc( 1000 );
                    ...
                    call_the_callback();  // might throw an exception
                    ...
                    free( p );
                  }
                  

                  如果异常有效",C 代码将无法捕获它,并且 p 将永远不会被释放.当然,图书馆可能分配的任何其他资源也是如此.

                  If the exception "works", the C code has no possible way of catching it, and p will never be freed. The same goes for any other resources the library may have allocated, of course.

                  这篇关于C++ 异常会安全地通过 C 代码传播吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                  How should a size-limited stl-like container be implemented?(应该如何实现大小受限的 stl 类容器?)
                  Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                  STL BigInt class implementation(STL BigInt 类实现)
                  Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                  Move list element to the end in STL(在 STL 中将列表元素移动到末尾)

                    <tbody id='Qyr2J'></tbody>
                  <legend id='Qyr2J'><style id='Qyr2J'><dir id='Qyr2J'><q id='Qyr2J'></q></dir></style></legend>

                • <i id='Qyr2J'><tr id='Qyr2J'><dt id='Qyr2J'><q id='Qyr2J'><span id='Qyr2J'><b id='Qyr2J'><form id='Qyr2J'><ins id='Qyr2J'></ins><ul id='Qyr2J'></ul><sub id='Qyr2J'></sub></form><legend id='Qyr2J'></legend><bdo id='Qyr2J'><pre id='Qyr2J'><center id='Qyr2J'></center></pre></bdo></b><th id='Qyr2J'></th></span></q></dt></tr></i><div id='Qyr2J'><tfoot id='Qyr2J'></tfoot><dl id='Qyr2J'><fieldset id='Qyr2J'></fieldset></dl></div>

                          <bdo id='Qyr2J'></bdo><ul id='Qyr2J'></ul>

                          <small id='Qyr2J'></small><noframes id='Qyr2J'>

                          <tfoot id='Qyr2J'></tfoot>