C++ says gcd is not a member of std
up vote
1
down vote
favorite
I am using visual studio 2017 and I have run across a problem. When trying to use std::gcd
it gives me an error error C2039: 'gcd': is not a member of 'std'
Here's my code:
#include "pch.h"
#include <iostream>
#include <numeric>
int main() {
std::cout << std::gcd(10, 5);
return 1;
}
c++ visual-studio-2017
add a comment |
up vote
1
down vote
favorite
I am using visual studio 2017 and I have run across a problem. When trying to use std::gcd
it gives me an error error C2039: 'gcd': is not a member of 'std'
Here's my code:
#include "pch.h"
#include <iostream>
#include <numeric>
int main() {
std::cout << std::gcd(10, 5);
return 1;
}
c++ visual-studio-2017
Did you enable-std=c++11
with your compiler flags?
– πάντα ῥεῖ
Nov 11 at 18:06
@πάνταῥεῖ im not sure what that means. But shouldn't i be using c++17?
– Joyal Mathew
Nov 11 at 18:10
Oh, sorry. It should be-std=c++17
according to the reference documentation
– πάντα ῥεῖ
Nov 11 at 18:14
4
@πάνταῥεῖ The command-line option in MSVS is/std:c++17
, not the same as GCC or Clang.
– Blastfurnace
Nov 11 at 18:16
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am using visual studio 2017 and I have run across a problem. When trying to use std::gcd
it gives me an error error C2039: 'gcd': is not a member of 'std'
Here's my code:
#include "pch.h"
#include <iostream>
#include <numeric>
int main() {
std::cout << std::gcd(10, 5);
return 1;
}
c++ visual-studio-2017
I am using visual studio 2017 and I have run across a problem. When trying to use std::gcd
it gives me an error error C2039: 'gcd': is not a member of 'std'
Here's my code:
#include "pch.h"
#include <iostream>
#include <numeric>
int main() {
std::cout << std::gcd(10, 5);
return 1;
}
c++ visual-studio-2017
c++ visual-studio-2017
edited Nov 11 at 18:06
πάντα ῥεῖ
71.3k972134
71.3k972134
asked Nov 11 at 18:04
Joyal Mathew
300112
300112
Did you enable-std=c++11
with your compiler flags?
– πάντα ῥεῖ
Nov 11 at 18:06
@πάνταῥεῖ im not sure what that means. But shouldn't i be using c++17?
– Joyal Mathew
Nov 11 at 18:10
Oh, sorry. It should be-std=c++17
according to the reference documentation
– πάντα ῥεῖ
Nov 11 at 18:14
4
@πάνταῥεῖ The command-line option in MSVS is/std:c++17
, not the same as GCC or Clang.
– Blastfurnace
Nov 11 at 18:16
add a comment |
Did you enable-std=c++11
with your compiler flags?
– πάντα ῥεῖ
Nov 11 at 18:06
@πάνταῥεῖ im not sure what that means. But shouldn't i be using c++17?
– Joyal Mathew
Nov 11 at 18:10
Oh, sorry. It should be-std=c++17
according to the reference documentation
– πάντα ῥεῖ
Nov 11 at 18:14
4
@πάνταῥεῖ The command-line option in MSVS is/std:c++17
, not the same as GCC or Clang.
– Blastfurnace
Nov 11 at 18:16
Did you enable
-std=c++11
with your compiler flags?– πάντα ῥεῖ
Nov 11 at 18:06
Did you enable
-std=c++11
with your compiler flags?– πάντα ῥεῖ
Nov 11 at 18:06
@πάνταῥεῖ im not sure what that means. But shouldn't i be using c++17?
– Joyal Mathew
Nov 11 at 18:10
@πάνταῥεῖ im not sure what that means. But shouldn't i be using c++17?
– Joyal Mathew
Nov 11 at 18:10
Oh, sorry. It should be
-std=c++17
according to the reference documentation– πάντα ῥεῖ
Nov 11 at 18:14
Oh, sorry. It should be
-std=c++17
according to the reference documentation– πάντα ῥεῖ
Nov 11 at 18:14
4
4
@πάνταῥεῖ The command-line option in MSVS is
/std:c++17
, not the same as GCC or Clang.– Blastfurnace
Nov 11 at 18:16
@πάνταῥεῖ The command-line option in MSVS is
/std:c++17
, not the same as GCC or Clang.– Blastfurnace
Nov 11 at 18:16
add a comment |
2 Answers
2
active
oldest
votes
up vote
6
down vote
accepted
std::gcd
was added in C++17. To use it in Visual Studio you need to specify the language standard. You can do that two ways, use the /std:c++17
command-line option or in the Project Properties dialog: C/C++ -> Language -> C++ Language Standard.
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
@JoyalMathew Here's documentation for the/std
option. It does default to C++14, you would have to ask them why.
– Blastfurnace
Nov 12 at 2:53
1
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
add a comment |
up vote
0
down vote
I just tested and got the same error with VS2017 15.8.9 after having set the language standard to C++17. When I checked my project settings again, the language setting I made had reverted back to the default. After having set it a second time, it worked.
This seems to happen often when I start a new project and change to C++17 directly.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
std::gcd
was added in C++17. To use it in Visual Studio you need to specify the language standard. You can do that two ways, use the /std:c++17
command-line option or in the Project Properties dialog: C/C++ -> Language -> C++ Language Standard.
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
@JoyalMathew Here's documentation for the/std
option. It does default to C++14, you would have to ask them why.
– Blastfurnace
Nov 12 at 2:53
1
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
add a comment |
up vote
6
down vote
accepted
std::gcd
was added in C++17. To use it in Visual Studio you need to specify the language standard. You can do that two ways, use the /std:c++17
command-line option or in the Project Properties dialog: C/C++ -> Language -> C++ Language Standard.
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
@JoyalMathew Here's documentation for the/std
option. It does default to C++14, you would have to ask them why.
– Blastfurnace
Nov 12 at 2:53
1
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
add a comment |
up vote
6
down vote
accepted
up vote
6
down vote
accepted
std::gcd
was added in C++17. To use it in Visual Studio you need to specify the language standard. You can do that two ways, use the /std:c++17
command-line option or in the Project Properties dialog: C/C++ -> Language -> C++ Language Standard.
std::gcd
was added in C++17. To use it in Visual Studio you need to specify the language standard. You can do that two ways, use the /std:c++17
command-line option or in the Project Properties dialog: C/C++ -> Language -> C++ Language Standard.
answered Nov 11 at 18:12
Blastfurnace
13.6k54058
13.6k54058
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
@JoyalMathew Here's documentation for the/std
option. It does default to C++14, you would have to ask them why.
– Blastfurnace
Nov 12 at 2:53
1
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
add a comment |
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
@JoyalMathew Here's documentation for the/std
option. It does default to C++14, you would have to ask them why.
– Blastfurnace
Nov 12 at 2:53
1
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
Thanks! I would assume that VS 2017 would use C++17 by default. Why isn't this the case?
– Joyal Mathew
Nov 12 at 2:44
@JoyalMathew Here's documentation for the
/std
option. It does default to C++14, you would have to ask them why.– Blastfurnace
Nov 12 at 2:53
@JoyalMathew Here's documentation for the
/std
option. It does default to C++14, you would have to ask them why.– Blastfurnace
Nov 12 at 2:53
1
1
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
@JoyalMathew: VS2017 is from May 2017, C++17 was approved in December 2017.
– MSalters
Nov 12 at 8:31
add a comment |
up vote
0
down vote
I just tested and got the same error with VS2017 15.8.9 after having set the language standard to C++17. When I checked my project settings again, the language setting I made had reverted back to the default. After having set it a second time, it worked.
This seems to happen often when I start a new project and change to C++17 directly.
add a comment |
up vote
0
down vote
I just tested and got the same error with VS2017 15.8.9 after having set the language standard to C++17. When I checked my project settings again, the language setting I made had reverted back to the default. After having set it a second time, it worked.
This seems to happen often when I start a new project and change to C++17 directly.
add a comment |
up vote
0
down vote
up vote
0
down vote
I just tested and got the same error with VS2017 15.8.9 after having set the language standard to C++17. When I checked my project settings again, the language setting I made had reverted back to the default. After having set it a second time, it worked.
This seems to happen often when I start a new project and change to C++17 directly.
I just tested and got the same error with VS2017 15.8.9 after having set the language standard to C++17. When I checked my project settings again, the language setting I made had reverted back to the default. After having set it a second time, it worked.
This seems to happen often when I start a new project and change to C++17 directly.
answered Nov 11 at 18:28
Ted Lyngmo
1,443314
1,443314
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53251638%2fc-says-gcd-is-not-a-member-of-std%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
Did you enable
-std=c++11
with your compiler flags?– πάντα ῥεῖ
Nov 11 at 18:06
@πάνταῥεῖ im not sure what that means. But shouldn't i be using c++17?
– Joyal Mathew
Nov 11 at 18:10
Oh, sorry. It should be
-std=c++17
according to the reference documentation– πάντα ῥεῖ
Nov 11 at 18:14
4
@πάνταῥεῖ The command-line option in MSVS is
/std:c++17
, not the same as GCC or Clang.– Blastfurnace
Nov 11 at 18:16