Can't compile C++ 17 structured bindings
The following code
#include <iostream>
#include <tuple>
int main()
{
auto [i, c, d] = std::make_tuple(1, 'a', 2.3);
std::cout << "i=" << i << " c=" << c << " d=" << d << 'n';
return 0;
}
doesn't get compiled on my computer. I get these error messages:
error: use of undeclared identifier 'i'
error: expected unqualified-id
and some more of the same type.
I'm using: Mac OS X 10.11.6 El Capitan, CLion. I did choose the C++ 17 option when I created the project and my CMakeList.txt has this line:set(CMAKE_CXX_STANDARD 17)
.
clang --version - Apple LLVM version 8.0.0 (clang-800.0.42.1)
What do I need to do to compile this code?
c++ c++17 clion
|
show 5 more comments
The following code
#include <iostream>
#include <tuple>
int main()
{
auto [i, c, d] = std::make_tuple(1, 'a', 2.3);
std::cout << "i=" << i << " c=" << c << " d=" << d << 'n';
return 0;
}
doesn't get compiled on my computer. I get these error messages:
error: use of undeclared identifier 'i'
error: expected unqualified-id
and some more of the same type.
I'm using: Mac OS X 10.11.6 El Capitan, CLion. I did choose the C++ 17 option when I created the project and my CMakeList.txt has this line:set(CMAKE_CXX_STANDARD 17)
.
clang --version - Apple LLVM version 8.0.0 (clang-800.0.42.1)
What do I need to do to compile this code?
c++ c++17 clion
1
Are you compiling as C++17 (-std=c++17
command line option)?
– Jesper Juhl
Jan 3 at 19:47
2
When compiling withcmake
-generated Makefiles, you can verify the-std=c++17
flag withmake VERBOSE=1
. Or export a compilation database and inspect it. The code should compile just fine.
– lubgr
Jan 3 at 19:49
1
My suggestion doesn't have anything to do with an IDE, manually compiling the code viamake VERBOSE=1
requires a terminal (but you should even be able to open one in CLion I guess) and knowing the path to your project build directory. Exporting a compilation data base is indeed done by editing aCMakeLists.txt
.
– lubgr
Jan 3 at 19:54
1
@alekscooper: Please edit your question (the title and example particularly) to make it clear that it is not about C++17 or structured bindings but about using CLion, then.
– Davis Herring
Jan 3 at 20:14
2
That older version of Xcode does not have complete C++17 support. (The current version has much better support, but not yet complete, iirc.)
– Eljay
Jan 3 at 20:32
|
show 5 more comments
The following code
#include <iostream>
#include <tuple>
int main()
{
auto [i, c, d] = std::make_tuple(1, 'a', 2.3);
std::cout << "i=" << i << " c=" << c << " d=" << d << 'n';
return 0;
}
doesn't get compiled on my computer. I get these error messages:
error: use of undeclared identifier 'i'
error: expected unqualified-id
and some more of the same type.
I'm using: Mac OS X 10.11.6 El Capitan, CLion. I did choose the C++ 17 option when I created the project and my CMakeList.txt has this line:set(CMAKE_CXX_STANDARD 17)
.
clang --version - Apple LLVM version 8.0.0 (clang-800.0.42.1)
What do I need to do to compile this code?
c++ c++17 clion
The following code
#include <iostream>
#include <tuple>
int main()
{
auto [i, c, d] = std::make_tuple(1, 'a', 2.3);
std::cout << "i=" << i << " c=" << c << " d=" << d << 'n';
return 0;
}
doesn't get compiled on my computer. I get these error messages:
error: use of undeclared identifier 'i'
error: expected unqualified-id
and some more of the same type.
I'm using: Mac OS X 10.11.6 El Capitan, CLion. I did choose the C++ 17 option when I created the project and my CMakeList.txt has this line:set(CMAKE_CXX_STANDARD 17)
.
clang --version - Apple LLVM version 8.0.0 (clang-800.0.42.1)
What do I need to do to compile this code?
c++ c++17 clion
c++ c++17 clion
edited Jan 3 at 20:38
Nicol Bolas
291k34481658
291k34481658
asked Jan 3 at 19:43
alekscooperalekscooper
327312
327312
1
Are you compiling as C++17 (-std=c++17
command line option)?
– Jesper Juhl
Jan 3 at 19:47
2
When compiling withcmake
-generated Makefiles, you can verify the-std=c++17
flag withmake VERBOSE=1
. Or export a compilation database and inspect it. The code should compile just fine.
– lubgr
Jan 3 at 19:49
1
My suggestion doesn't have anything to do with an IDE, manually compiling the code viamake VERBOSE=1
requires a terminal (but you should even be able to open one in CLion I guess) and knowing the path to your project build directory. Exporting a compilation data base is indeed done by editing aCMakeLists.txt
.
– lubgr
Jan 3 at 19:54
1
@alekscooper: Please edit your question (the title and example particularly) to make it clear that it is not about C++17 or structured bindings but about using CLion, then.
– Davis Herring
Jan 3 at 20:14
2
That older version of Xcode does not have complete C++17 support. (The current version has much better support, but not yet complete, iirc.)
– Eljay
Jan 3 at 20:32
|
show 5 more comments
1
Are you compiling as C++17 (-std=c++17
command line option)?
– Jesper Juhl
Jan 3 at 19:47
2
When compiling withcmake
-generated Makefiles, you can verify the-std=c++17
flag withmake VERBOSE=1
. Or export a compilation database and inspect it. The code should compile just fine.
– lubgr
Jan 3 at 19:49
1
My suggestion doesn't have anything to do with an IDE, manually compiling the code viamake VERBOSE=1
requires a terminal (but you should even be able to open one in CLion I guess) and knowing the path to your project build directory. Exporting a compilation data base is indeed done by editing aCMakeLists.txt
.
– lubgr
Jan 3 at 19:54
1
@alekscooper: Please edit your question (the title and example particularly) to make it clear that it is not about C++17 or structured bindings but about using CLion, then.
– Davis Herring
Jan 3 at 20:14
2
That older version of Xcode does not have complete C++17 support. (The current version has much better support, but not yet complete, iirc.)
– Eljay
Jan 3 at 20:32
1
1
Are you compiling as C++17 (
-std=c++17
command line option)?– Jesper Juhl
Jan 3 at 19:47
Are you compiling as C++17 (
-std=c++17
command line option)?– Jesper Juhl
Jan 3 at 19:47
2
2
When compiling with
cmake
-generated Makefiles, you can verify the -std=c++17
flag with make VERBOSE=1
. Or export a compilation database and inspect it. The code should compile just fine.– lubgr
Jan 3 at 19:49
When compiling with
cmake
-generated Makefiles, you can verify the -std=c++17
flag with make VERBOSE=1
. Or export a compilation database and inspect it. The code should compile just fine.– lubgr
Jan 3 at 19:49
1
1
My suggestion doesn't have anything to do with an IDE, manually compiling the code via
make VERBOSE=1
requires a terminal (but you should even be able to open one in CLion I guess) and knowing the path to your project build directory. Exporting a compilation data base is indeed done by editing a CMakeLists.txt
.– lubgr
Jan 3 at 19:54
My suggestion doesn't have anything to do with an IDE, manually compiling the code via
make VERBOSE=1
requires a terminal (but you should even be able to open one in CLion I guess) and knowing the path to your project build directory. Exporting a compilation data base is indeed done by editing a CMakeLists.txt
.– lubgr
Jan 3 at 19:54
1
1
@alekscooper: Please edit your question (the title and example particularly) to make it clear that it is not about C++17 or structured bindings but about using CLion, then.
– Davis Herring
Jan 3 at 20:14
@alekscooper: Please edit your question (the title and example particularly) to make it clear that it is not about C++17 or structured bindings but about using CLion, then.
– Davis Herring
Jan 3 at 20:14
2
2
That older version of Xcode does not have complete C++17 support. (The current version has much better support, but not yet complete, iirc.)
– Eljay
Jan 3 at 20:32
That older version of Xcode does not have complete C++17 support. (The current version has much better support, but not yet complete, iirc.)
– Eljay
Jan 3 at 20:32
|
show 5 more comments
1 Answer
1
active
oldest
votes
As @Eljay said in the comments, older versions of clang did (do) not have complete C++17 support.
I have reproduced this issue w/o CLion.
On a 10.11.6 machine, using "Apple LLVM version 8.0.0 (clang-800.0.42.1)"
clang++ -std=c++1z junk.cpp
gives the errors that the OP reported. (Note that -std=c++17
is not a valid option here - that came later)
On a 10.14.2 machine, using "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"
clang++ -std=c++17 junk.cpp
compiles w/o error.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54028803%2fcant-compile-c-17-structured-bindings%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As @Eljay said in the comments, older versions of clang did (do) not have complete C++17 support.
I have reproduced this issue w/o CLion.
On a 10.11.6 machine, using "Apple LLVM version 8.0.0 (clang-800.0.42.1)"
clang++ -std=c++1z junk.cpp
gives the errors that the OP reported. (Note that -std=c++17
is not a valid option here - that came later)
On a 10.14.2 machine, using "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"
clang++ -std=c++17 junk.cpp
compiles w/o error.
add a comment |
As @Eljay said in the comments, older versions of clang did (do) not have complete C++17 support.
I have reproduced this issue w/o CLion.
On a 10.11.6 machine, using "Apple LLVM version 8.0.0 (clang-800.0.42.1)"
clang++ -std=c++1z junk.cpp
gives the errors that the OP reported. (Note that -std=c++17
is not a valid option here - that came later)
On a 10.14.2 machine, using "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"
clang++ -std=c++17 junk.cpp
compiles w/o error.
add a comment |
As @Eljay said in the comments, older versions of clang did (do) not have complete C++17 support.
I have reproduced this issue w/o CLion.
On a 10.11.6 machine, using "Apple LLVM version 8.0.0 (clang-800.0.42.1)"
clang++ -std=c++1z junk.cpp
gives the errors that the OP reported. (Note that -std=c++17
is not a valid option here - that came later)
On a 10.14.2 machine, using "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"
clang++ -std=c++17 junk.cpp
compiles w/o error.
As @Eljay said in the comments, older versions of clang did (do) not have complete C++17 support.
I have reproduced this issue w/o CLion.
On a 10.11.6 machine, using "Apple LLVM version 8.0.0 (clang-800.0.42.1)"
clang++ -std=c++1z junk.cpp
gives the errors that the OP reported. (Note that -std=c++17
is not a valid option here - that came later)
On a 10.14.2 machine, using "Apple LLVM version 10.0.0 (clang-1000.10.44.4)"
clang++ -std=c++17 junk.cpp
compiles w/o error.
answered Jan 3 at 21:49
Marshall ClowMarshall Clow
7,4521533
7,4521533
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54028803%2fcant-compile-c-17-structured-bindings%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Are you compiling as C++17 (
-std=c++17
command line option)?– Jesper Juhl
Jan 3 at 19:47
2
When compiling with
cmake
-generated Makefiles, you can verify the-std=c++17
flag withmake VERBOSE=1
. Or export a compilation database and inspect it. The code should compile just fine.– lubgr
Jan 3 at 19:49
1
My suggestion doesn't have anything to do with an IDE, manually compiling the code via
make VERBOSE=1
requires a terminal (but you should even be able to open one in CLion I guess) and knowing the path to your project build directory. Exporting a compilation data base is indeed done by editing aCMakeLists.txt
.– lubgr
Jan 3 at 19:54
1
@alekscooper: Please edit your question (the title and example particularly) to make it clear that it is not about C++17 or structured bindings but about using CLion, then.
– Davis Herring
Jan 3 at 20:14
2
That older version of Xcode does not have complete C++17 support. (The current version has much better support, but not yet complete, iirc.)
– Eljay
Jan 3 at 20:32