错误的模板参数数量

use*_*374 1 c++ systemc

我对cpp没有多少经验,更不用说systemc了.

为什么要做这项工作?

sc_in<sc_uint<8>> a,b;
Run Code Online (Sandbox Code Playgroud)

adder.cpp:5:错误:'a'未在此范围内声明
adder.cpp:5:错误:'b'未在此范围内声明
adder.cpp:5:错误:模板参数数量错误(2,应该是1)

这确实有效:

sc_in<int> a,b;
Run Code Online (Sandbox Code Playgroud)

Lig*_*ica 7

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

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

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

如果你已经设法走得那么远,它会在以后抱怨两个丢失的>角色;,讽刺的是带你回到你开始的地方.

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

这是在C++ 11中修复的.