Macro to replace C++ operator new

后端 未结 7 1841
臣服心动
臣服心动 2020-12-04 13:47

Is it possible to create macros to replace all forms of operator new with overloads that include additional args...say __FILE__ and __LINE__<

7条回答
  •  孤城傲影
    2020-12-04 14:14

    You don't say what compiler you are using, but at least with GCC, you can override new and log the caller address, then later translate that to file/line information with addr2line (or use the BFD library to do that immediately).

提交回复
热议问题