我在VSC中用C++编写了一个简单的代码,当我编译它时,cl会给我一些错误,即使它编译得很好。代码是:
#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;
}
我得到的错误消息是:
C:\ Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\ostream(284):Files (x86)\Microsoft Visual Program warning C4530:使用了C++异常处理程序,但未启用展开语义。指定/EHsc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\ostream(269):注意:编译类模板成员函数'std::basic_ostream &std::basic_ostream::operator <<(X86)‘时
triplex.cpp(22):注意:参见对正在编译的函数模板实例化'std::basic_ostream &std::basic_ostream::operator <<(int)‘的引用
triplex.cpp(7):注意:参见对正在编译的类模板实例化'std::basic_ostream‘的引用
有人能给我解释一下这些是什么吗?提前感谢!
发布于 2021-06-23 17:31:13
这只是一个警告,它会告诉你这一点:exception handler used, but unwind semantics are not enabled. Specify /EHsc。如果您在project properties->c/c++->Code generation->enable c++ exceptions下将其设置为Yes (/EHsc)(实际上它应该是默认值),那么您就可以运行了。
https://stackoverflow.com/questions/68097067
复制相似问题