我使用SystemC教程安装了这库2.3.1。
我写了这个hello world示例:
//hello.cpp
#include <systemc.h>
SC_MODULE (hello_world) {
SC_CTOR (hello_world) {
}
void say_hello() {
cout << ”Hello World systemc-2.3.0.\n”;
}
};
int sc_main(int argc, char* argv[]) {
hello_world hello(“HELLO”);
hello.say_hello();
return(0);
}并使用以下命令编译:
export SYSTEMC_HOME=/usr/local/systemc230/
g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -Wl,-rpath=$SYSTEMC_HOME/lib-linux -o hello hello.cpp -lsystemc -lm在编译代码时,库中出现了一个错误:
In file included from hello.cpp:1:0:
/usr/local/systemc230/include/systemc.h:118:16: error: ‘std::gets’ has not been declared
using std::gets;
^~~~我怎么才能解决这个问题?
发布于 2016-07-13 14:00:56
std::gets已在C++11中删除(参见在C11中,gets()等价于什么?)
如果使用C++11标志进行构建(可能使用g++别名),则必须在systemc.h中禁用这一行。
替换
using std::gets;使用
#if defined(__cplusplus) && (__cplusplus < 201103L)
using std::gets;
#endif发布于 2017-03-20 18:50:43
正如guyguy333所提到的,在新版本中,g++是C++11的别名,所以添加-std=c++98可以解决这个问题。编译命令可能如下所示
$ g++ -std=c++98 -lsystemc -pthread main.cpp -o main发布于 2016-07-13 13:30:02
你似乎已经复制了网页上的代码。请记住"“和”“不是一回事。在第8行
cout << ”Hello World systemc-2.3.0.\n”;代之以
cout << "Hello World systemc-2.3.0.\n";在第13行
hello_world hello(“HELLO”);代之以
hello_world hello("HELLO");然后再执行代码。GoodLuck。
https://stackoverflow.com/questions/38352801
复制相似问题