By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,127 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,127 IT Pros & Developers. It's quick & easy.

Strange access/scope resolution errors

P: n/a
I have some code that I am porting over from C. It is full of static
functions and global variables. I have got around this by wrapping most
of the code in a singleton object.

However, I am findng that in my method definitions, I am having to fully
scope the names of any other functions I am calling. I do not understand
this. The clas declaration code look some thing like this:

class A: public Singleton<A> {
public:
A();
~A() ;

private:
A (const A&)

struct1 x ;
int b ;
........
foo1() ;
foo2() ;
};
The implementation looks like this:

A::foo1() {
foo2() ; // <- compiler coplains here (dosent know about fo2
....
}

The actual compiler error msg is:
error C3861: 'foo2': identifier not found, even with argument-dependent
lookup.

However, this works:

A::foo1() {
A::foo2() ; // <- compiler coplains here (dosent know about fo2
....
}

Why?. I have never had to explicitly name functions before, and these
are uniquely named functions. Thanks
Jul 24 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Alfonso Morra" <sw***********@the-ring.com> wrote in message
news:db**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com
I have some code that I am porting over from C. It is full of static
functions and global variables. I have got around this by wrapping
most of the code in a singleton object.

However, I am findng that in my method definitions, I am having to
fully scope the names of any other functions I am calling. I do not
understand this. The clas declaration code look some thing like this:

class A: public Singleton<A> {
public:
A();
~A() ;

private:
A (const A&)

struct1 x ;
int b ;
........
foo1() ;
foo2() ;
};

The implementation looks like this:

A::foo1() {
foo2() ; // <- compiler coplains here (dosent know about fo2
....
}

The actual compiler error msg is:
error C3861: 'foo2': identifier not found, even with
argument-dependent lookup.

I don't believe this. Present some real compileable code that shows the
error (I have a suspicion what your real code looks like, but we shouldn't
have to guess).
--
John Carson

Jul 24 '05 #2

P: n/a


John Carson wrote:
"Alfonso Morra" <sw***********@the-ring.com> wrote in message
news:db**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com
I have some code that I am porting over from C. It is full of static
functions and global variables. I have got around this by wrapping
most of the code in a singleton object.

However, I am findng that in my method definitions, I am having to
fully scope the names of any other functions I am calling. I do not
understand this. The clas declaration code look some thing like this:

class A: public Singleton<A> {
public:
A();
~A() ;

private:
A (const A&)

struct1 x ;
int b ;
........
foo1() ;
foo2() ;
};

The implementation looks like this:

A::foo1() {
foo2() ; // <- compiler coplains here (dosent know about fo2
....
}

The actual compiler error msg is:
error C3861: 'foo2': identifier not found, even with
argument-dependent lookup.


I don't believe this. Present some real compileable code that shows the
error (I have a suspicion what your real code looks like, but we
shouldn't have to guess).


I can understand your incredulity. This had me baffled for most part of
the day yesterday. I am quite sure that I'm doing something that is
quite simply, foolish - but I probably need a another set of eyes to
point this out/spot the error.

There is too much code to post here, The following is a much, much
abridged version (I have removed the Singleton inheritance - to simplify
the code - the errors still occur):

class SharedMemory {
private:
//definition of internal structures
// required in other struct definitions later
typedef struct _sys {...} SYSTEM ;
typedef struct _bny {...} BARNEY ;

public:
typedef struct _slice {...} POOL_SLICE ;
typedef struct _hdr {...} POOL_HEADER ; //has member of type SYSTEM
static enum { ... }SLICE_TYPES ; //'static' keyword hack to get code
to compile, bcos I needed to
initialize an element.

private:
//Prevent copy and assignement
SharedMemory(const SharedMemory&) ;
SharedMemory& operator=( const SharedMemory&) ;
typedef struct _sem{ ... } SEMAPHORE ;
typedef struct _lcpy{ ...} LOCAL_COPY ;

/* Private var */
int var1 ;
POOL_HEADER* hdr ;
LOCAL_CPY *shmcpy ;
.....

/* private methods */
POOL_HEADER *get_header() ;
POOL_SLICE *get_slice() ;
int foobar() ;
...
};
Implemenntation:

SharedMemory::POOL_Header* SharedMemory::getHeader() {
int a = foobar(); //I need an explicit name here!
return hdr ; // causes errors:
(1). needs explicit name SharedMemory::hdr
(2). after name change, compiler complains: "illegal
reference to non-static member SharedMemory::hdr'"
}
Another thing I forgot to mention in my earlier post was that I cannot
also, reference (private) local variables (e.g. var1), without either a
fully resolved name (i.e. SharedMemory::var1), or by using the 'this'
pointer (e.g. this->var1). This is quite strange, as I have never come
accross this before, and it is also making the code quite unreadable.

Any ideas, suggestions will be welcome.

Tks

Jul 24 '05 #3

P: n/a


Alfonso Morra wrote:


John Carson wrote:
"Alfonso Morra" <sw***********@the-ring.com> wrote in message
news:db**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com
I have some code that I am porting over from C. It is full of static
functions and global variables. I have got around this by wrapping
most of the code in a singleton object.

However, I am findng that in my method definitions, I am having to
fully scope the names of any other functions I am calling. I do not
understand this. The clas declaration code look some thing like this:

class A: public Singleton<A> {
public:
A();
~A() ;

private:
A (const A&)

struct1 x ;
int b ;
........
foo1() ;
foo2() ;
};

The implementation looks like this:

A::foo1() {
foo2() ; // <- compiler coplains here (dosent know about fo2
....
}

The actual compiler error msg is:
error C3861: 'foo2': identifier not found, even with
argument-dependent lookup.



I don't believe this. Present some real compileable code that shows
the error (I have a suspicion what your real code looks like, but we
shouldn't have to guess).


I can understand your incredulity. This had me baffled for most part of
the day yesterday. I am quite sure that I'm doing something that is
quite simply, foolish - but I probably need a another set of eyes to
point this out/spot the error.

There is too much code to post here, The following is a much, much
abridged version (I have removed the Singleton inheritance - to simplify
the code - the errors still occur):

class SharedMemory {
private:
//definition of internal structures
// required in other struct definitions later
typedef struct _sys {...} SYSTEM ;
typedef struct _bny {...} BARNEY ;

public:
typedef struct _slice {...} POOL_SLICE ;
typedef struct _hdr {...} POOL_HEADER ; //has member of type SYSTEM
static enum { ... }SLICE_TYPES ; //'static' keyword hack to get code
to compile, bcos I needed to
initialize an element.

private:
//Prevent copy and assignement
SharedMemory(const SharedMemory&) ;
SharedMemory& operator=( const SharedMemory&) ;
typedef struct _sem{ ... } SEMAPHORE ;
typedef struct _lcpy{ ...} LOCAL_COPY ;

/* Private var */
int var1 ;
POOL_HEADER* hdr ;
LOCAL_CPY *shmcpy ;
.....

/* private methods */
POOL_HEADER *get_header() ;
POOL_SLICE *get_slice() ;
int foobar() ;
...
};
Implemenntation:

SharedMemory::POOL_Header* SharedMemory::getHeader() {
int a = foobar(); //I need an explicit name here!
return hdr ; // causes errors:
(1). needs explicit name SharedMemory::hdr
(2). after name change, compiler complains: "illegal
reference to non-static member SharedMemory::hdr'"
}
Another thing I forgot to mention in my earlier post was that I cannot
also, reference (private) local variables (e.g. var1), without either a
fully resolved name (i.e. SharedMemory::var1), or by using the 'this'
pointer (e.g. this->var1). This is quite strange, as I have never come
accross this before, and it is also making the code quite unreadable.

Any ideas, suggestions will be welcome.

Tks


Not to worry. I've now fixed the problem. error messages turned out to
be a bit of a red herring ..

Jul 24 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.