| Summary: | CDT cannot parse make_shared<> from <memory> in C++0x mode | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Matt Hargett <matt> |
| Component: | cdt-parser | Assignee: | Sergey Prigogin <eclipse.sprigogin> |
| Status: | RESOLVED FIXED | QA Contact: | Markus Schorn <mschorn.eclipse> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug, eclipse.sprigogin, yevshif, zeratul976 |
| Version: | 8.0 | ||
| Target Milestone: | 8.1.0 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Bug Depends on: | 327297 | ||
| Bug Blocks: | |||
Works for me using g++ 4.5, most likely the header uses a c++11 feature we don't yet support. Since CDT doesn't support all C++11 features in GCC 4.6 and 4.7, it can't accurately parse the standard library headers of those compilers. What I do is install GCC 4.5 on the machine as well, and get CDT to look at the 4.5 headers instead of the 4.6 or 4.7 ones. One way to do this is to go to Project Properties -> C/++ Build -> Discovery Options, and change the "Compiler invocation command" from g++ to g++-4.5. Then "Clear" the discovered entries and rebuild the project to get CDT to re-acquire them. You can verify in C/C++ General -> Paths and Symbols (Symbols tab) that CDT discarded the 4.6/4.7 headers and picked up the 4.5 ones. Note however that if you do this, then CDT won't be able to handle range-based for loops correctly, because the std::begin and std::end functions that are implicitly used by the range-based for loop are not present in the 4.5 headers (they were introduced in 4.6). You can work around *that* too, by copying the 4.5 library's <iterator> file to some folder in your Eclipse include path, and pasting the std::begin and std::end function definitions from the 4.6 version (they are in <bits/range_access.h>) into there. Hopefully, the Juno version of CDT will have full support for C++11 features used in GCC 4.6, and then these workarounds won't be necessary any more. Fixed in master by commit http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=e55325538485fe691418c4b50c7a4d947239d95c. |
Build Identifier: Build id: 20111215-0110 (CDT Version: 8.1.0.201201101828) After adding -std=c++0x (or -std=c++11, in the case of GCC 4.7 trunk) to the Discovery Scanner, I am still getting an error ("Symbol 'make_shared' could not be resolved) on any line that mentions make_shared: #include <memory> #include <string> int main(void) { auto bob = std::make_shared<std::string>("bob"); return bob->length(); } This compiled fine for me locally with g++ 4.6 and 4.7 (trunk), with no warnings. I've been getting this codebase to be free of errors from the CDT parser and CODAN, and this is a stumbling block. Reproducible: Always