samng Posted July 5, 2013 Report Share Posted July 5, 2013 I am trying to implement float and fixed and point computation using the same code using sc_fixed<> and type casting sc_fxcast_switch(). For this, I created a class template and added the type casting code: template <sc_switch FIXPT> class abc { sc_fxcast_switch fxc(FIXPT); sc_fxcast_context fxc_context(fxc); // members sc_fixed<....> a, b, c; ..... } However, the compiler does not seem to like having the type casting code in class declaration, error in VS2010: error C2061: syntax error : identifier 'fxc' Can sc_fxcast_context/switch be members of a class? If not, how do you control the cast switch sc_fixed<> members? Thanks, Sam Quote Link to comment Share on other sites More sharing options...
dakupoto Posted July 5, 2013 Report Share Posted July 5, 2013 Hello, It appears that you are using MS Visual C++. Please note that MS Visual C++ has a number of restricted prefixes that cannot be used. You would have to check the compiler manual for these. Quote Link to comment Share on other sites More sharing options...
apfitch Posted July 6, 2013 Report Share Posted July 6, 2013 (edited) If you're using the ASI Proof of Concept simulator, have you defined the define that enables fixed point, SC_INCLUDE_FX ? Alan P.S. And of course you can't initialize at declaration in a class! Edited July 6, 2013 by apfitch maehne 1 Quote Link to comment Share on other sites More sharing options...
samng Posted July 6, 2013 Author Report Share Posted July 6, 2013 Alan, I did define SC_INCLUDE_FX and sc_fixed type is working fine. Dakupoto, The context switch code if put in functions/methods works fine. It seems that it just don't like it in class declaration. Sam Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted July 6, 2013 Report Share Posted July 6, 2013 As Alan said, you can't initialize a class member within the body of the class definition in C++ (not SystemC specific). You need to write a constructor instead. Something like: template <sc_switch FIXPT> class abc { sc_fxcast_switch fxc; sc_fxcast_context fxc_context; // members sc_fixed<....> a, b, c; public: // default constructor abc() : fxc(FIXPT) , fxc_context(fxc) {} // ... }; Greetings from Oldenburg, Philipp ralph.goergen and maehne 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.