# Problem passing a ptr to a fxn into a fxn

Printable View

• 04-07-2004
*Bob_ptr
Problem passing a ptr to a fxn into a fxn
I am using the wavelet code from numerical recipes in C.
http://www.library.cornell.edu/nr/bookcpdf/c13-10.pdf
When I try to call a function that calls another function I get the following error in MS Visual C++:

wavelet.obj : error LNK2001: unresolved external symbol "void __cdecl wt1(float *,unsigned long,int,void (__cdecl*)(float *,unsigned long,int))" (?wt1@@YAXPAMKHP6AX0KH@Z@Z)
Debug/w3.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

The relevant code is as follows:

void daub4(float *, unsigned long, int);
void wt1(float *, unsigned long, int, void (*)(float [], unsigned long, int));

void main(){
...
wt1(x, numPoints-1, 1, daub4);
...
}

void wt1(float a[], unsigned long n, int isign,
float(*wtstep)(float [], unsigned long, int)){
//One-dimensional discrete wavelet transform. This routine implements the pyramid algorithm,
//replacing a[1..n] by its wavelet transform (for isign=1), or performing the inverse operation
//(for isign=-1)
//. Note that n MUST be an integer power of 2. The routine wtstep, whose
//actual name must be supplied in calling this routine, is the underlying wavelet .lter. Examples
//of wtstep are daub4 and (preceded by pwtset) pwt.
unsigned long nn;

if (n < 4) return;
if (isign >= 0) { //Wavelet transform.
for (nn=n;nn>=4;nn>>=1) (*wtstep)(a,nn,isign);
//Start at largest hierarchy, and work towards smallest.
} else { //Inverse wavelet transform.
for (nn=4;nn<=n;nn<<=1) (*wtstep)(a,nn,isign);
//Start at smallest hierarchy, and work towards largest.
}
}

void daub4(float *a, unsigned long n, int isign){
.......
.......
}

Please help me to pass daub4 into wt1!

Thanks,
*Bob_ptr
• 04-07-2004
Dave_Sinkula
Code:

`void wt1(float *, unsigned long, int, void (*)(float [], unsigned long, int));`
Code:

```void wt1(float a[], unsigned long n, int isign,         float(*wtstep)(float [], unsigned long, int)) {```
Make the declaration match the definition.
• 04-07-2004
Prelude
Code tags will make your declaration/definition mismatch problems easier to find. And for those of us that still eyeball the unformatted code, we rarely miss this:
Code:

`void main(){`
main returns int for the majority of software. If you're giving us code from a freestanding environment then mention it so that we don't jump all over you. Otherwise, you're wrong and we're right. :)