2

I dont have much experience in cpp, let alone systemc.

Why doenst this work?

sc_in<sc_uint<8>> a,b;

adder.cpp:5: error: ‘a’ was not declared in this scope
adder.cpp:5: error: ‘b’ was not declared in this scope
adder.cpp:5: error: wrong number of template arguments (2, should be 1)

This does work:

sc_in<int> a,b;
4

1 回答 1

8

在 C++03 中,你不能让这两个>字符彼此相邻,因为编译器认为你正在尝试执行右移。

然后它变得非常困惑,认为你的意思是:

sc_in<sc_uint<(8 >> a), b;
//                  ^ ^ ^
//                  ? | ?   Compiler: "what are `a` and `b`?!"
//                    !     Compiler: "why two arguments?!"

如果你能做到这一点,它稍后会抱怨>之前缺少的两个字符;,讽刺的是带你回到你开始的地方。

你必须改写sc_in<sc_uint<8> >

这是从 C++11 开始修复的。

于 2014-11-26T01:38:37.273 回答