gpt4 book ai didi

c++ - C++ “expected primary-expression before ‘(’ token ”错误

转载 作者:行者123 更新时间:2023-12-02 11:15:49 24 4
gpt4 key购买 nike

我有以下代码:

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: error: expected primary-expression before ‘(’ token
nodes.cpp:544:94: error: expected ‘)’ before ‘;’ token



我不知道这可能是什么,特别是因为该代码示例包含另一个执行相同操作的语句,并且不会引起错误。

最佳答案

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))
) // This closes the function call
; // You didn't close the throw here!

关于c++ - C++ “expected primary-expression before ‘(’ token ”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6115580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com