Is there a gcc option to assume all extern “C” functions cannot propagate exceptions?

前端 未结 4 1428
别那么骄傲
别那么骄傲 2021-02-01 16:35

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

4条回答
  •  梦如初夏
    2021-02-01 17:12

    When exception is raised it generate interrupt which unroll stack and override existing stack. It goes up to the point where try/except syntax is. This mean than you do not have any overhead if you do not use exceptions. Only overhead in memory/time is at try/catch blocks and stack unrolling at throw().

    If your c functions does not generate exceptions your overhead will be only in space when you will call try/catch in your C++ but is same for any number of exceptions. (and small time overhead on initialising this small space whit constant).

提交回复
热议问题