库的系统c 错误
Systemc Error with the library
我使用本教程安装了SystemC库2.3.1。
我写了这个你好世界的例子:
//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;
^~~~
我该如何解决这个问题?
std::gets
已在C++11 中删除(请参阅在 C11 中等效的 gets() 是什么?)
如果使用 C++11 标志(可能使用 g++ 别名)进行构建,则必须在 systemc.h
中禁用此行。
取代
using std::gets;
跟
#if defined(__cplusplus) && (__cplusplus < 201103L)
using std::gets;
#endif
正如guyguy333所提到的,在新版本中,g++是C++11的别名。因此,添加-std=c++98
将解决问题。编译命令可能像
$ g++ -std=c++98 -lsystemc -pthread main.cpp -o main
您似乎已经按原样从网页上复制了代码。请记住"和"不是一回事。在第 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");
然后再次执行代码。祝你好运。
相关文章:
- 错误处理.将系统错误代码映射到泛型
- C++系统找不到指定的文件错误
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- 获取 clang++:错误:在编译文件系统库的代码时
- 系统错误:程序无法启动,因为您的计算机中缺少MSVCP140D.DLL。尝试重新安装该程序以解决此问题
- 设置我的应用程序 API 感知并防止系统使其模糊和错误定位
- C++ VS 错误:<实验/文件系统>提供 std::experimental::文件系统的标头已被Microsoft弃用,将被删除
- 试图建立银行管理系统,但有错误
- Boost进程"系统"功能中的错误处理
- 我需要帮助创建一个评分系统,但它一直给我一个错误,注释掉的整数是给我带来麻烦的部分
- 将 std::文件系统头文件添加到我的程序时出现编译错误
- 错误:尝试在全新系统安装中构建应用程序后未定义对'...'的引用
- 使用特征 3 线性系统求解器的错误结果
- 来自提升的分段错误(提升:文件系统:存在)
- 读取系统() 命令错误响应消息
- "<某些系统标头>:错误:"<在此处插入函数>"在移动源文件后不是"std"的成员
- 针对 QNX 交叉编译后,boost 文件系统 (1.63) 失败并出现未定义的引用错误
- 错误 C2440:无法将"系统::D rawing::位图"转换为"系统::对象"
- Valgrind 错误:系统调用参数 epoll_pwait(sigmask) 指向不可寻址的字节
- 需要一个健壮的win32 GUI应用程序错误系统