• <small id='sclNE'></small><noframes id='sclNE'>

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

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

        时间:2023-08-01
          <tfoot id='zCEUp'></tfoot>
          <i id='zCEUp'><tr id='zCEUp'><dt id='zCEUp'><q id='zCEUp'><span id='zCEUp'><b id='zCEUp'><form id='zCEUp'><ins id='zCEUp'></ins><ul id='zCEUp'></ul><sub id='zCEUp'></sub></form><legend id='zCEUp'></legend><bdo id='zCEUp'><pre id='zCEUp'><center id='zCEUp'></center></pre></bdo></b><th id='zCEUp'></th></span></q></dt></tr></i><div id='zCEUp'><tfoot id='zCEUp'></tfoot><dl id='zCEUp'><fieldset id='zCEUp'></fieldset></dl></div>

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

              • <bdo id='zCEUp'></bdo><ul id='zCEUp'></ul>

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

                1. 本文介绍了C++ 异常会通过 C 代码安全地传播吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个 C++ 应用程序,它调用 SQLite(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 代码安全地传播吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:C++ 异常处理增加了多少占用空间 下一篇:C++ - 返回码异常的参数

                  相关文章

                  最新文章

                2. <small id='Zrz1z'></small><noframes id='Zrz1z'>

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

                  <tfoot id='Zrz1z'></tfoot>

                  1. <legend id='Zrz1z'><style id='Zrz1z'><dir id='Zrz1z'><q id='Zrz1z'></q></dir></style></legend>

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