Search code examples
c++compiler-errorscl

CL Unknown Errors


I have written a simple code in C++ in VSC and when I compile it cl gives me some errors, even though it compiles it just fine. The code is:

#include <iostream>


int main()
{   
    //  Print welcome messages to the terminal
    std::cout << "You are a secret agent breaking into a secure server room\n";
    std::cout << "You need to enter the correct codes to continue..." << std::endl;

    //Declare 3 number code
    const int CodeA = 4;
    const int CodeB = 3;
    const int CodeC = 2;

    
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProduct = CodeA * CodeB * CodeC;

    // Print sum and product to the terminal
    std::cout << std::endl;
    std::cout << "+ There are 3 numbers in the code" << std::endl;
    std::cout << "+ The codes add-up to: " << CodeSum << std::endl;
    std::cout << "+ The code multiply to give: " << CodeProduct << std::endl << std::endl;

    int GuessA, GuessB, GuessC;
    std::cin >> GuessA;
    std::cin >> GuessB;
    std::cin >> GuessC;
    std::cout << "You entered: " << GuessA << GuessB << GuessC << std::endl;

    return 0;
}

And the error messages I am getting are:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\ostream(284): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\ostream(269): note: while compiling class template member function 'std::basic_ostream<char,std::char_traits> &std::basic_ostream<char,std::char_traits>::operator <<(int)'

triplex.cpp(22): note: see reference to function template instantiation 'std::basic_ostream<char,std::char_traits> &std::basic_ostream<char,std::char_traits>::operator <<(int)' being compiled

triplex.cpp(7): note: see reference to class template instantiation 'std::basic_ostream<char,std::char_traits>' being compiled

Can someone explain to me what these are? Thanks in advance!


Solution

  • That's just warning, it tells you exactly this: exception handler used, but unwind semantics are not enabled. Specify /EHsc. If you go under project properties->c/c++->Code generation->enable c++ exceptions and set it to Yes (/EHsc)(it should be the default value actually) and you are good to go.