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;
}









share|improve this question
























  • 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















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;
}









share|improve this question
























  • 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













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;
}









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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.






share|improve this answer





















  • 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


















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.






share|improve this answer





















    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',
    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
    });


    }
    });














    draft saved

    draft discarded


















    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

























    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.






    share|improve this answer





















    • 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















    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.






    share|improve this answer





















    • 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













    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.






    share|improve this answer












    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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


















    • 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












    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 18:28









        Ted Lyngmo

        1,443314




        1,443314






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python