how can a NanAsyncWorker parameter be "undeclared identifier"

104 views Asked by At

I have this code (from https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate )

class PiWorker : public NanAsyncWorker {
public:
    PiWorker( NanCallback *callback, NanUtf8String sz_QMN )
    : NanAsyncWorker( callback ) {}     
    ~PiWorker() {}

void Execute() {
    printf( "(cc)>>>> qmn [%s].\n", sz_QMN ) ; .... line 52

... and compiler says

..\mqconn.cc(52): error C2065: 'sz_QMN' : undeclared identifier

How can it be ?

1

There are 1 answers

0
rodrigopandini On

Did you declare sz_QMN as private member?
From the nan example, the Execute() function only access the private members.
You can initialize the sz_QMN private member in your constructor:

public:
PiWorker(NanCallback *callback, NanUtf8String sz_QMN)
: NanAsyncWorker(callback), sz_QMN(sz_QMN) {}