miracl / MIRACL

MIRACL Cryptographic SDK: Multiprecision Integer and Rational Arithmetic Cryptographic Library is a C software library that is widely regarded by developers as the gold standard open source SDK for elliptic curve cryptography (ECC).
https://miracl.com
651 stars 242 forks source link

"Error Using << Operator with std::cout in Visual Studio 2022 on Windows 11“ #132

Open 12shuaibi opened 2 weeks ago

12shuaibi commented 2 weeks ago

Issue Description I am encountering an issue when trying to use std::cout in various C++ programs compiled using Visual Studio 2022 on Windows 11. Whenever I attempt to use the << operator with std::cout to print a variable, I get the following errors during compilation:

Error (active) E0349: No operator "<<" matches these operands Error C2678: Binary "<<" : no operator found which takes a left-hand operand of type "std::basic_ostream<char,std::char_traits>" (or there is no acceptable conversion)

This error appears in multiple programs, not just when using the Big type from the MIRACL library.

Example Code Here is one of the example programs where the issue occurs. The code is meant to calculate the factorial of a number using MIRACL's Big type:

extern "C" {

include

}

include

include

using namespace std;

Miracl precision(500, 10); // This makes sure that MIRACL is initialised before main() is called

int main() { Big nf = 1; // declare "Big" variable nf int n; cout << "factorial program\n"; cout << "input number n= \n"; cin >> n;

while (n > 1)
    nf *= (n--); // nf=n!=n*(n-1)*(n-2)*....3*2*1

cout << "n!= \n" << nf << "\n"; // This line causes the error

}

However, I've also encountered the same error in simpler programs that don't involve the Big type. It appears that Visual Studio 2022 is struggling to find a valid overload for the << operator in these cases.

System Information Operating System: Windows 11 Development Environment: Visual Studio 2022