visitor99999
visitor99999

Reputation: 163

typedef an sc_fixed but got template error

Trying to define a simple sc_fixed type in Visual Studio 2017:

#include <systemc.h>
#include <sysc/datatypes/fx/sc_fixed.h>   # just in case
....
typedef sc_fixed<16, 4> fixed_type;
....

This typedef line resulted an error:

E0864: sc_fixed is not a template

Had no idea why this error popped, even included sysc/datatypes/fx/sc_fixed.h. Why does it say "not a template"?

Upvotes: 1

Views: 476

Answers (2)

Graham Brown
Graham Brown

Reputation: 21

I got the same type of error message in one of my C++ programs - E0864 - unique_ptr is not a template

I managed to get rid of this error in my program by adding this to my header file.

#include <memory>

My program managed to compile okay using this. I am using Visual Studio 2019 if that helps.

Upvotes: 0

Jellybaby
Jellybaby

Reputation: 996

From INSTALL file shipped with SystemC

SystemC 2.3 includes a fixed-point package that is always built. When compiling your applications with fixed-point types, you still have to use compiler flag -DSC_INCLUDE_FX. Note that compile times increase significantly when using this compiler flag.

Using your code as an example

#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;
}

Gives me the output

ft = 1.25

As a caveat it is best to check the docs for your particular version of SystemC as I believe this #define may have been removed in 2.3.3 (I am using 2.3.2) I am not certain.

Upvotes: 0

Related Questions