Reputation: 1428
I get these errors messages all over the place for g++ 4.1.2, and it doesn't help at all:
<file>:<line>: error: expected primary-expression before 'int'
<file>:<line>: error: expected ';' before 'int'
<file>:<line>: error: invalid use of qualified-name '::SuccessCode'
The piece of code where it happens is as simple as this:
class Test
{
static Status debug_function(void)
{
return Status::SuccessCode(); // this would be <file>:<line> mentioned above
// and this one too:
// return Status::FailureCode("test");
}
};
And here's the code for Status (and yes it's properly included, because I would have an error if the include file was invalid):
namespace CODES
{
enum Values { Success = 0, Failed = 1 };
}
class Status
{
private:
CODES::Values code;
string msg;
public:
Status(CODES::Values val, const string &i_msg ): code(val), msg(i_msg) {}
static Status SuccessCode(void)
{
return Status(CODES::Success, "");
}
static Status FailureCode(const string &fail_msg)
{
return Status(CODES::Failed, fail_msg);
}
};
So, what is wrong with this piece of code ? And it compiles properly under VC++!
EDIT: Actually, the code for SuccessCode and FailureCode are in a *.cpp file. I put them in the class declaration because the error message is still the same!
Upvotes: 0
Views: 138
Reputation: 168596
Without a complete program, I'll have to guess. My guess is: you have a #define Status int
somewhere in your program.
Upvotes: 2