visual studio – I got an error when trying to use GMP library on C++ windows


I have a project and i want to use the GNU GMP library. I am using C++ and code using Microsoft Visual Studio 2022. I have downloaded, built the library using MSYS and have installed it into the ide. I wrote this as the first code just to test

#include <iostream>
#include <gmpxx.h>

int main() {

    mpz_class a, b;
    a = 123;
    b = "456";
    return 0;

}

But when i tried to compile the code, i got a warning and a bunch of errors, the first warning is this

Severity    Code    Description Project File    Line    Suppression State   Details
Warning    C4244    'return': conversion from 'mp_limb_t' to 'unsigned long', possible loss of data gmp C:\GMP\include\gmp.h    1792        

and the next subsequent errors are the same type but just at different lines

Severity    Code    Description Project File    Line    Suppression State   Details
Error      C4146    unary minus operator applied to unsigned type, result still unsigned    gmp C:\GMP\include\gmp.h    2237        

Leave a Reply

Your email address will not be published. Required fields are marked *