Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Systemc Error with the library

I installed the SystemC library 2.3.1 using this tutorial.

I wrote this hello world example:

//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);
}

and compiled with this command:

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

When I compile the code, I got a error with the library:

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;
                ^~~~

How can I solve this?

like image 468
Álison Venâncio Avatar asked Jul 13 '16 13:07

Álison Venâncio


2 Answers

std::gets has been removed in C++11 (See What is gets() equivalent in C11?)

If you're building using C++11 flag (maybe with a g++ alias), you have to disable this line in systemc.h.

Replace

using std::gets;

with

#if defined(__cplusplus) && (__cplusplus < 201103L)
using std::gets;
#endif
like image 79
Guillaume Avatar answered Oct 17 '22 02:10

Guillaume


As guyguy333 mentioned, in new versions, g++ is an alias for C++11. so adding -std=c++98 would solve the problem. The compile command may like

$ g++ -std=c++98 -lsystemc -pthread main.cpp -o main
like image 1
Pazel1374 Avatar answered Oct 17 '22 02:10

Pazel1374