wrong number of template arguments

628 views Asked by At

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;
1

There are 1 answers

0
Lightness Races in Orbit On BEST ANSWER

In C++03, you can't have the two > characters next to each other because the compiler thinks you're trying to perform a right shift.

It then gets really confused, thinking you mean this:

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

If you had managed to get that far, it would later complain about the two missing > characters before ;, ironically taking you back to where you started.

You have to write sc_in<sc_uint<8> > instead.

That's fixed as of C++11.