I am using Eclipse Luna 2 CDT and having a wierd issue with indexer. The indexer fails with "const" for parameter. I am using C++11 and other c++11 functions work fine.
Sample Class
class Test {
public:
int getX();
}
this works with no issue in eclipse
void method(Test& t) {
t.getX();
}
This gives wierd invalid arguments exception:Invalid arguments 'Candidates are:int getX()'
void method(const Test& t) {
t.getX(); //ERROR: Invalid arguments in eclipse
}
My question is why can Eclipse not work with const parameter. This works find with the build gcc build with no issue.
C ++ compiler, in order to prevent you from accidentally modifying objects, constants can not call non-const object suffix method.
we can fix like this:
int getX() const;
const object and non-const object both can call it.
why clang compiler work,maybe a clang issue(we could search later) or some optimization leads to ignore checking.
ADD:
9119 clang C++ unassignedclangbugs RESO DUPL no error calling non-const method on const object and something else.
I think this is clang issue,new version maybe fix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.