-2

I'm using Visual Studio 2017. I have a problem in writing GCD code and I can't find out any mistake. The errors are "identifier not found", and "gcd is unidentified". Here is my code:

#include "stdafx.h"
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    cout << __gcd(12, 40); 
}

1 Answers1

2

It's a hidden gem in libstdc++ but not in MSVC. Reference

I am able to call this function on an Ubuntu 16.04 install as well as Windows Subsystem for Linux, but not Windows.

Note as well, there's a std::gcd() function available in C++17, in header numeric. See the same reference above.

iBug
  • 35,554
  • 7
  • 89
  • 134