I am using C++ and as we all know we have this function __gcd(a,b). but for some reason using this was giving me error. So I thought it was my c++ version and changed it in Vscode. So now it shows in Vscode that i have that new version but when i run the program in terminal (there is a specific program which tells the version of c++ you are using in Vscode, i'll put link below) it still shows me old version that I was using. Therefore i still have same error. Pls someone help.
heres link: https://coderslegacy.com/c/check-cpp-compiler-version/
Can you send your code here?
there is nothing to send i just say cout <<__gcd(3,5); and its giving me error
all the code and all the included libraries.
Are you using #include cmath?
Which compiler do you use? For example MSVC doesn't have it
Anyways you can just use std::gcd
i don't know i haven't changed anything since downloading c++ on vscode. it still give me error when i use std::gcd(a,b) like howw
Please don't “download c++ on vscode” unless you know clearly what programs are installed. Just get to know more about different compilers and choose one to install on your machine. Sometimes a shortcut may bring you more pain afterward.
__gcd(a,b)
is a compiler-specific extension and may not be available in all environments.Use
gcd(a,b)
instead, from#include <numeric>
.std::gcd
is part of the C++17 standard, making it portable and reliable across different compilers.it sill gives me same error
Could you please add the error message here.
./AA.cpp:23:7: error: use of undeclared identifier '__gcd' d = __gcd(a,b);
Error Messege while you are using
gcd(3,4)
pleaseit doesn't show me anything else just that on terminal
contact saini_84 for vs code issues , contact number — 9381796116