-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cling] error: function definition is not allowed here
when trying to overload operator<=
#9449
Comments
@sbmorphe, thanks for reporting! This is a good catch! In this case, cling is trying to wrap the input as it thinks See also the related issue #9171. @vgvassilev and I recently talked about this, which has to be addressed also for clang-repl. As a workaround, you can either temporarily turn on raw input, or define the function in an anonymous namespace, i.e. [cling]$ .rawInput 1
[cling]$ bool operator<=(const A &lhs, const A &rhs) { return ((lhs.pod1 <= rhs.pod1) && (lhs.pod2 <= rhs.pod2)); }
[cling]$ .rawInput 0 or [cling]$ namespace { bool operator<=(const A &lhs, const A &rhs) { return ((lhs.pod1 <= rhs.pod1) && (lhs.pod2 <= rhs.pod2)); } } |
error: function definition is not allowed here
when trying to overload operator<=
Fixes root-project#9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
Fixes root-project#9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
Fixes root-project#9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
Fixes root-project#9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
Fixes #9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
Fixes root-project/root#9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
Hi @jalopezg-git, It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise. Sincerely, |
Fixes root-project#9449 so it is possible to define operator overload in cling cmd prompt. btw, Make SkipPointerRefs() to not assume next token being a tok::raw_identifier since it can be a global-scoped identifier, e.g. int* ::class_a::func_b(short c) { return nullptr; }
When trying to define an operator in the cling cli repl, the "function definition is not allowed here" error is generated. "cling -version" reports "0.8". Here's a copy/paste of a session to demonstrate the issue:
The text was updated successfully, but these errors were encountered: