n member function 'void ModCicComb::cycle(int64_t, int64_t, bool, bool)':
../modciccomb.cpp:57: error: no matching function for call to 'UtilGain::cycle(<unresolved overloaded function type>, <unresolved overloaded function type>, long int, bool&, bool&)'
What am I doing wrong? Is the template unable to work with the int64_t type? Thanks.
UtilGain<int64_t> gain; //default ctor assumed ( or you can substitute for the apt ctor)
//calling cycle function:
gain.cycle (stage.at(LAST_CIC_COMB_STAGE).getIOut,
stage.at(LAST_CIC_COMB_STAGE).getQOut,
pSoc->modHost.getValue(MOD_HOSTCICGAIN),
clockEnable,
resetFlag);
I'm not sure I understand this. As you probably deduced, gain is an object of type UtilGain. It's defined in the include file of the including object. So, where should the first line in your code go: in the constructor for the including class?
If i understand correctly, another object needs the functionality provided by UtilGain::cycle and that 's why it's being included. Should that be the case, then within the function body where cycle is to be used, a UtilGain object first needs to be instantiated with the requisite constructor before being called as i demonstrated.
Aargh. You got it, ne555...sloppy work on my part.
I am now getting a link-time error, though.
Undefined symbols:
"void UtilGain::cycle<long long>(long long, long long, long, bool, bool)", referenced from:
ModCicComb::cycle(long long, long long, bool, bool)in modciccomb.o
Let me provide a bit more detail. The gain object is part of another object, ModCicComb. the relevant portion of the modciccomb.h file looks like this:
OK...my situation is a bit more complicated than I thought. I'm trying to define a template function to support two classes of my creation. One represents a 32-bit register, and the other, a 64-bit register.
The rub is, many of the functions (including a constructor) take input data types dependent upon the class: the 32-bit register takes longs, while the 64-bit register takes input of type int64_t.
So...this (for example) was wrong:
1 2 3 4 5 6 7
template <class R> void UtilGain::cycle(
R gainInpI,
R gainInpQ,
long hostGain,
bool clockEnable,
bool resetFlag)
{ ...
gainInpI and gainInpQ should be long if R is a 32-bit register, and int64_t if R is a 64-bit register. Is there a way to accomplish this?
No. Although I'm wondering why you need that kind of functionality. Couldn't you just make gainInpI and Q long long ints (or whatever) always then just truncate it when you put it in the register?
Maybe that would work. The UtilGain class is going to be used by various other objects, some of which will have 32-bit registers and some 64. Won't the linker give me an error if I try to pass a long to a function expecting a long long?
EDIT: I tried it, and it built OK. I guess I don't remember the C++ rules of type conversion as well as I thought.