尝试在 Visual Studio 2017 中定义一个简单的 sc_fixed 类型:
#include <systemc.h>
#include <sysc/datatypes/fx/sc_fixed.h> # just in case
....
typedef sc_fixed<16, 4> fixed_type;
....
此 typedef 行导致错误:
E0864: sc_fixed is not a template
不知道为什么会弹出这个错误,甚至包括 sysc/datatypes/fx/sc_fixed.h。为什么说“不是模板”?
答案 0 :(得分:0)
来自 SystemC 附带的 INSTALL 文件
<块引用>SystemC 2.3 包含一个始终构建的定点包。 使用定点类型编译应用程序时,您仍然有 使用编译器标志 -DSC_INCLUDE_FX。请注意,编译时间会增加 使用此编译器标志时显着。
以您的代码为例
#include <systemc.h>
#include <sysc/datatypes/fx/sc_fixed.h>
#include <iostream>
typedef sc_dt::sc_fixed<16, 4> fixed_type;
int sc_main(int, char**){
fixed_type ft(1.25);
std::cout << "ft = " << ft << '\n';
return 0;
}
给我输出
ft = 1.25
作为警告,最好检查您的 SystemC 特定版本的文档,因为我相信这 #define
可能 已在 2.3.3 中删除(我使用的是 2.3.2 ) 我不确定。