0

CLion doesn't seem to recognize c++ tuples, although I can build and run my program from the terminal.

When trying to build, I only get "Build failed", while all the members of tuple are highlighted and I'm getting "Can't resolve namespace member tuple" (same with tie and make_tuple).

Here is my simple test:

#include<iostream>
#include<tuple>
std::tuple<int,int> testTuple();

int main(int argc, char** argv) {
    int a, b;
    std::tie(a,b) = testTuple();
    std::cout<<a<<" "<<b;
    return 0;
}
std::tuple<int,int> testTuple()
{
    return std::make_tuple(0,1);
}

My CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
project(testTuple)
SET(CMAKE_CXX_COMPILER, /usr/bin/g++-4.8)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_BUILD_TYPE Debug)

set(SOURCE_FILES "src/main.cpp")
add_executable(simplification ${SOURCE_FILES})
Mihai Bujanca
  • 4,089
  • 10
  • 43
  • 84
  • You don't get it, do you? [MCVE] as usual please, including verbatim error messages. BTW the [tag:clion] tag is probably irrelevant here. – πάντα ῥεῖ May 10 '16 at 17:28
  • @πάνταῥεῖ this only has to do with `clion` - doesn't have much to do with `cmake`, I think. While CLion does rely on cmake, it is not a cmake - related issue. I am running cmake on the same file in the terminal and it does work. I supplied more information related to the fail, although there isn't much more that I can find relevant. – Mihai Bujanca May 10 '16 at 17:47
  • @πάνταῥεῖ that being said, I think this is Minimal: can't think of a simpler test program. Complete: this is all the code, and all the information that I have. The inspector is highlighting it as an error, the build fails in clion but works in command line, and the only message when building is "Build failed". Verifiable: fire up CLion, copy-paste the code and the CMakeLists.txt and it can be tested – Mihai Bujanca May 10 '16 at 17:51
  • @BujancaMihai is [this](http://stackoverflow.com/a/28592565/955273) of any use? – Steve Lorimer May 11 '16 at 13:22
  • @BujancaMihai - I don't agree with the downvotes - but this is SO so you have to expect it. It might be a good idea to add a screenshot showing the code in CLion and the build failure? – Steve Lorimer May 11 '16 at 13:24
  • @BujancaMihai another possible [answer](http://stackoverflow.com/a/25900342/955273) – Steve Lorimer May 11 '16 at 13:24
  • @BujancaMihai [More possible help](https://www.reddit.com/r/learnprogramming/comments/3scwxg/c_how_do_i_get_clioncmake_to_use_c11/) – Steve Lorimer May 11 '16 at 13:27
  • @SteveLorimer sorry for not replying earlier. I can add a screenshot, but there is really no more information that it would provide, I think. All the build says is "build failed". Other C++11 features like range-based loops are recognized and work. A thing I noticed is that Clion labels `#include` as an unused import statement. So it might be that somehow it does include the functions in `` but doesn't recognize the functions as belonging to the header – Mihai Bujanca May 12 '16 at 16:12
  • @BujancaMihai what version of what compiler are you using? Is the CLion IDE using a different compiler to the once you are on the command line? – Steve Lorimer May 12 '16 at 16:17
  • @BujancaMihai please also add screenshot from `settings | build, execution, deployment | toolchains` – Steve Lorimer May 12 '16 at 16:18
  • @BujancaMihai you might also want to [enable verbose build output](http://superuser.com/questions/1065550/show-full-build-output-in-clion) – Steve Lorimer May 12 '16 at 16:18
  • 1
    @SteveLorimer I just updated Clion to 2016.1.2, and the issue is solved for me – Mihai Bujanca May 12 '16 at 16:50
  • 1
    @BujancaMihai nice one! – Steve Lorimer May 12 '16 at 17:09

1 Answers1

0

For implementing such features as code-competition, jump to definitions and so on features CLion has it's own c++ parser. So if your code compiled, but CLion show some kind of errors, go and report bug to jetbrain (https://youtrack.jetbrains.com/issues/CPP)

fghj
  • 8,898
  • 4
  • 28
  • 56
  • I'm trying to first determine if it's something that I did wrong (maybe there was some configuration step in CLion that I'm not aware of?) before submitting it as a bug – Mihai Bujanca May 10 '16 at 17:48
  • @BujancaMihai `CLion` take information about how to compile your project from `CMakeLists.txt`. Not important which part fails - parsing cmake file, or it's internal parser, both parts have one root - bug in `CLion`. – fghj May 10 '16 at 17:51