FUnction pointer link error

Hi Guys... I have the following class
namespace kcdag{
namespace logic{
namespace PpySuscripcion{
namespace PpySuscripcionCommon{

class PpySuscripcionWsClient
{
private:
static int (*m_fsendOriginal)(struct soap*, const char*, size_t)
public:
// all publics methods
};
}
}
}
}

the problem is when I compile the code there is no problem, but the linker said

undefined symbol: _ZN5kcdag5logic14PpySuscripcion20PpySuscripcionCommon22PpySuscripcionWsClient15m_frecvOriginalE

what is the problem and how can I fix it ??

regards
Thank for your answer... I thought that m_fsendOriginal is my function pointer and my local variable... until I know, its behavior is as any other pointer, but in this case is a function pointer...

So my friend, how would be ?? because now I'm not clear about how canI do it
and my local variable
It is a static variable of class. They have to be defined beforehand.

its behavior is as any other pointer
Yes. The fact that it is a function pointer is irrelevant. You would be having same problem with just a simple int.

So my friend, how would be ?? because now I'm not clear about how canI do it
Define it in implementation file of your class:
1
2
3
4
5
//A type alias to avoid typing function pointer type in future
using Ppyfsend = int (*)(struct soap*, const char*, size_t); 

//Set m_fsendOriginal to null pointer at start
Ppyfsend PpySuscripcionWsClient::m_fsendOriginal = nullptr;
I had write this:

1
2
    using Ppyfsend = int (*)(struct soap*, const char*, size_t);
    Ppyfsend PpySuscripcionWsClient::m_frecvOriginal; 


and the output was:
PpySuscripcionWsClient.h:48:11: error: expected nested-name-specifier before ‘Ppyfsend’
PpySuscripcionWsClient.h:48:11: error: using-declaration for non-member at class scope
PpySuscripcionWsClient.h:48:20: error: expected ‘;’ before ‘=’ token
PpySuscripcionWsClient.h:48:20: error: expected unqualified-id before ‘=’ token
PpySuscripcionWsClient.h:50:5: error: ‘Ppyfsend’ does not name a type


Compiler give those errors... what I missing ? :(
First of all this should not be in header file. Put it in implementation file.
this code

using Ppyfsend = int (*)(struct soap*, const char*, size_t);

is a c++11 code until I know, If I use this declaration in the cpp file, I had the following error:

PpySuscripcionWsClient.cpp:23:11: error: expected nested-name-specifier before ‘Ppyfsend’
PpySuscripcionWsClient.cpp:23:11: error: ‘Ppyfsend’ has not been declared
PpySuscripcionWsClient.cpp:23:20: error: expected ‘;’ before ‘=’ token
PpySuscripcionWsClient.cpp:23:20: error: expected unqualified-id before ‘=’ token
Why not use C++11?

However if you insist on not using it, replace it with
typedef int (*Ppyfsend )(struct soap*, const char*, size_t);
because the system is deployed in old debian version using gcc 4.1, and I'm new in my job (only 3 weeks)... I love c++14, in my personal projects I work with it because clang support it, but in my job i can't use it !!!
Topic archived. No new replies allowed.