Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Code doesn't compile with 4.2.1: (2 Items)
   
Code doesn't compile with 4.2.1  
template <class T>
class SharedMemory
{
public:
	SharedMemory() : m_fd(-1)
	{
	}
	
public:
	int 			m_fd;
	
};

template <class T>
class SharedMemoryCreator : public SharedMemory<T>
{
public:
	SharedMemoryCreator()
	{
		m_fd = 0;
	}
};

int main(void)
{

//SharedMemoryCreator<float> p;

  return 0;

}

This code compiles fine with 3.3.5 but doesn't with 4.2.1.  The problem is m_fd = 0  for which the compiler says:

error: 'm_fd' was not declared in this scope

I'm not sure if this is a problem with my code not being compliant with latest C++ or if it's a specific QNX 4.2.1 bug.

- Mario
Re: Code doesn't compile with 4.2.1  
Hi Mario,

This is gcc 4.2.1 being more compliant to the C++ standard. The C++ parser was rewritten in gcc 3.4 to improve 
performance and adhere closer to the standard. The gcc 3.4 changes page contains a list of invalid constructs that were 
once accepted and are now rejected. 

In your case: " In a template definition, unqualified names will no longer find members of a dependent base (as 
specified by [temp.dep]/3 in the C++ standard)"

http://gcc.gnu.org/gcc-3.4/changes.html#cplusplus

You should be able to prefix m_fd with "this->" and be compatible with gcc 3.3. 

Please let me know if you have any questions.

Regards,

Ryan Mansfield