【发布时间】:2013-02-07 16:57:44
【问题描述】:
我有一个.cc 文件,它同时使用了iostream 和malloc。我怎样才能编译它?使用g++,它说
error: 'malloc' was not declared in this scope
使用gcc,它说
fatal error: iostream: No such file or directory
源码位于http://sequitur.info/sequitur_simple.cc
更新
我将malloc 更改为new 并将free 更改为delete。我仍然有很多错误。例如
/usr/include/c++/4.6/new:103:14: error: initializing argument 2 of âvoid* operator new(std::size_t, void*)â [-fpermissive]
【问题讨论】:
-
您必须
#include相应的文件。 -
malloc是有效的 c++ -
你能构建源代码吗?
-
@KarthikT,但混合起来不是一个好主意
-
是的
#includeing<stdlib.h>有帮助,也可以使用<string.h>,因为您正在使用memset()。我编译了做那些模组的代码。