C++ “‘(’ token”错误之前预期的主表达式
我有这个代码:
FILE *f = fopen(intPath, "r");
Node *n;
if (f) {
try {
n = parse(f, intPath);
} catch (SyntaxError e) {
fclose(f); /***** line 536 *****/
throw LangException(
builtin_classes::exception_class::create_ImportError(
String::fromAscii(e.filename)->
append(String::fromAscii(":"))->
append(String::fromInt(e.line))->
append(String::fromAscii(":"))->
append(String::fromInt(e.col))->
append(String::fromAscii(": syntax error: "))->
append(String::fromAscii(e.message))
);
}
fclose(f);
return n->eval(scope);
} else {
throw LangException(
builtin_classes::exception_class::create_ImportError(
String::fromAscii("failed to open file for reading")
),
line,
col
);
}
编译器给出了这个错误:
nodes.cpp:537:40: 错误:
'('
标记之前需要主表达式
nodes.cpp:544:94: 错误:在';'
令牌之前应有')'
我不知道它可能是什么,特别是因为该代码示例有另一个语句它做同样的事情,并且不会导致错误。
I have this code:
FILE *f = fopen(intPath, "r");
Node *n;
if (f) {
try {
n = parse(f, intPath);
} catch (SyntaxError e) {
fclose(f); /***** line 536 *****/
throw LangException(
builtin_classes::exception_class::create_ImportError(
String::fromAscii(e.filename)->
append(String::fromAscii(":"))->
append(String::fromInt(e.line))->
append(String::fromAscii(":"))->
append(String::fromInt(e.col))->
append(String::fromAscii(": syntax error: "))->
append(String::fromAscii(e.message))
);
}
fclose(f);
return n->eval(scope);
} else {
throw LangException(
builtin_classes::exception_class::create_ImportError(
String::fromAscii("failed to open file for reading")
),
line,
col
);
}
And the compiler gives this error:
nodes.cpp:537:40: error: expected primary-expression before
‘(’
token
nodes.cpp:544:94: error: expected‘)’
before‘;’
token
I have no clue what it could be, especially since that code sample has another statement which does the same thing, and it doesn't cause an error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的
(
和)
在那个大的第一个throw LangException
块中不匹配。Your
(
and your)
don't match in that large, firstthrow LangException
block.编译器会告诉你哪里出了问题。
throw LangException(
没有)
。The compiler tells you what is wrong. The
throw LangException(
doesn't have a)
.正是它所说的。该行的
';'
标记之前缺少')'
。没有关闭。
Exactly what it says. You are missing a
‘)’
before‘;’
token on that line.is not closed.