Jump to content


Photo

Unhelpful Error Message "missing Right Brace"


2 replies to this topic

#1 Stephen Tarr

Stephen Tarr

    Newbrie

  • Members
  • 3 posts

Posted 25 October 2012 - 04:27 PM

I'm having troubles with some method declarations in one of my classes. I can work around one of the issues but don't have a solution for the second. I've stripped down my code to produce the example here.

Issue #1: in the declaration of the copy constructor, BoostC++ requires that I declare the argument as "const class SEGPTR &ptr" while G++ requires only "const SEGPTR &ptr". Apparently, BoostC++ doesn't recognize SEGPTR as a class name until after it's parsed the entire class declaration, while G++ recognizes the type name as soon as it's seen the opening brace of the definition.

The workaround is easy: either declare SEGPTR to be a class name (e.g. with "class SEGPTR;") before launching into the definition or add the keyword "class" where needed. But this is a portability issue and the error messages aren't very helpful.

Issue #2: the compiler reports "error: missing right brace" at the first line of the assignment operator definition. I haven't been able to find what's causing this error and the error message is not at all helpful. What's going on here and how can I create a working declaration?

Thanks,
-Steve

#include <system.h>
 
// segmented pointer example
 
class SEGPTR {
private:
	unsigned char m_seg;
	unsigned char m_off;
 
public:
	// default constructor
	SEGPTR() {
		m_seg = 0;
		m_off = 0;
	};
 
	// copy constructor
	// BoostC++ requires "const class SEGPTR &ptr"
	// while G++ requires only "const SEGPTR &ptr".
	SEGPTR( const class SEGPTR &ptr ) {
		m_seg = ptr.m_seg;
		m_off = ptr.m_off;
	};
 
	// assignment
	// BoostC++ rejects this definition with
	//   "error: missing right brace".
	SEGPTR& operator= ( const class SEGPTR &ptr ) {
		m_seg = ptr.m_seg;
		m_off = ptr.m_off;
		return *this;
	};
 
	// other methods here...
};


#2 Pavel

Pavel

    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 1,451 posts
  • Gender:Male
  • Location:Melbourne, Australia

Posted 25 October 2012 - 10:05 PM

BoostC++ is not a full blown C++ compiler and supports only a subset of the C++ language. This particular error that you reported was caused by the operator overloading that is not supported by BoostC++.

Regards,
Pavel


#3 Stephen Tarr

Stephen Tarr

    Newbrie

  • Members
  • 3 posts

Posted 26 October 2012 - 04:33 AM

OK, thank you. I suspected as much, but couldn't find anything in the documentation that specifically listed that as a known limitation, and the error message wasn't much help. Please consider this an enhancement request to at recognize the "operator" keyword and perhaps other common but unsupported features and flag them with specific errors or warnings of their own.
-Steve



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users