系统错误与库错误

Ali*_*cio 5 c++ hardware fpga systemc asic

我使用教程安装了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);
}
Run Code Online (Sandbox Code Playgroud)

并使用此命令编译:

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
Run Code Online (Sandbox Code Playgroud)

当我编译代码时,我得到了一个库错误:

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;
                ^~~~
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

Gui*_*ume 13

std::gets已在C++ 11中删除(请参阅C11中的什么是gets()等效?)

如果您使用C++ 11标志构建(可能使用g ++别名),则必须禁用此行systemc.h.

更换

using std::gets;
Run Code Online (Sandbox Code Playgroud)

#if defined(__cplusplus) && (__cplusplus < 201103L)
using std::gets;
#endif
Run Code Online (Sandbox Code Playgroud)