You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS下调用mallinfo()编译C/C++代码失败求助

macOS下GCC编译调用mallinfo函数报错问题

我在MacOS系统的C代码里使用mallinfo函数时遇到了问题。已经在源文件中包含了<stdlib.h>,但用GNU gcc 12.3.0版本编译代码时仍出现如下错误:

MPI/worker.C: In member function 'int64_t Worker::cmembytes1(uint64_t*)':
MPI/worker.C:181:19: error: aggregate 'Worker::cmembytes1(uint64_t*)::mallinfo minf' has incomplete type and cannot be defined
  181 |   struct mallinfo minf;
      |                   ^~~~
MPI/worker.C:182:19: error: invalid use of incomplete type 'struct Worker::cmembytes1(uint64_t*)::mallinfo'
  182 |   minf = mallinfo() ;
      |                   ^
MPI/worker.C:181:10: note: forward declaration of 'struct Worker::cmembytes1(uint64_t*)::mallinfo'
  181 |   struct mallinfo minf;
      |          ^~~~~~~~
make: *** [<builtin>: MPI/worker.o] Error 1

更新: 我猜测问题根源是混合使用了macOS原生头文件与GNU头文件,在引入macOS SDK以使用mallinfo()时出现了定义冲突。

内容的提问来源于stack exchange,提问作者mabalenk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 18:29:53