C++/C语言独立内存分配

标签 c++ c memory-management

<分区>

定义一个转换为 C++ 的 new 和 C 的 malloc 的宏是常见的做法吗? (以及等效的删除/释放宏)

最佳答案

Is it common practice to define a macro that translates to new for C++ and malloc for C? (And an equivalent delete/free macro)

没有。

I was wondering if such a thing is common practice because I have never seen it in use in any programs but I can't think of any reason why it would be a bad thing to do

C 不是 C++。 C++ 不是 C。绝对没有理由这样做。

关于C++/C语言独立内存分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20363456/

相关文章:

c++ - 即使我解压了 4.8.1,GCC -v 也会返回 GCC 4.7.3?

c++ - 单字节变量的 boost::program_options

c - 如何手动引起中断?

c - Windows 上是否有 sbrk(0) 的等价物

java - 在运行 SonarQube 和扫描仪时,我得到 "insufficient memory for JRE to continue"

c++ - 这段代码是如何运行的?

c++ - 在 Qt Creator 中自动增加内部版本号

c++ - 将这种原始指针情况变成 unique_ptr?

c - 如何在 Nim 中访问指针数组的元素?

c - c中for循环的一个例子