Блог пользователя altrko

Автор altrko, история, 9 дней назад, По-английски

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/

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
8 дней назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Can you send your code here?

  • »
    »
    8 дней назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    there is nothing to send i just say cout <<__gcd(3,5); and its giving me error

    • »
      »
      »
      8 дней назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      all the code and all the included libraries.

      • »
        »
        »
        »
        8 дней назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится
        // this is code
        
        #include <bits/stdc++.h>
        using namespace std;
        
        #define ll long long
        #define N (int) 2e5
        #define mod (ll) 1e9+7
        
        ll aa[N],ans;
        
        int main ()
        {
            
            ios::sync_with_stdio(false);
        	cin.tie(NULL);cout.tie(NULL);
        
        	cout <<__gcd(3,4)<<endl;
        
        
        }
        
        
»
8 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Are you using #include cmath?

»
8 дней назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Which compiler do you use? For example MSVC doesn't have it

Anyways you can just use std::gcd

  • »
    »
    8 дней назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    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

    • »
      »
      »
      8 дней назад, # ^ |
      Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

      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.

»
8 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

__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.

  • »
    »
    8 дней назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    it sill gives me same error

    • »
      »
      »
      8 дней назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Could you please add the error message here.

      • »
        »
        »
        »
        8 дней назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        ./AA.cpp:23:7: error: use of undeclared identifier '__gcd' d = __gcd(a,b);

      • »
        »
        »
        »
        8 дней назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Error Messege while you are using gcd(3,4) please

        • »
          »
          »
          »
          »
          7 дней назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          it doesn't show me anything else just that on terminal

»
6 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

contact saini_84 for vs code issues , contact number — 9381796116