Jump to content
Stephen Tarr

Unhelpful Error Message "missing Right Brace"

Recommended Posts

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...
};

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×