CL 未知错误
CL Unknown Errors
我在 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:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30037\include\ostream(284):警告 C4530:使用了 C++ 异常处理程序,但未启用展开语义。指定 /EHsc
C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30037\include\ostream(269): 注意:编译时class模板成员函数'std::basic_ostream<char,std::char_traits> &std::basic_ostream<char,std::char_traits>::operator <<(int)'
triplex.cpp(22): 注意:参见函数模板实例化参考 'std::basic_ostream<char,std::char_traits> &std::basic_ostream<char,std::char_traits>::operator <<(int)' 正在编译
triplex.cpp(7):注意:请参阅参考 class 模板实例化 'std::basic_ostream<char,std::char_traits>' 正在编译
谁能给我解释一下这些是什么?
提前致谢!
这只是警告,它准确地告诉您:exception handler used, but unwind semantics are not enabled. Specify /EHsc
。
如果你进入 project properties->c/c++->Code generation->enable c++ exceptions
并将其设置为 Yes (/EHsc)
(实际上它应该是默认值),你就可以开始了。
我在 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:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30037\include\ostream(284):警告 C4530:使用了 C++ 异常处理程序,但未启用展开语义。指定 /EHsc
C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30037\include\ostream(269): 注意:编译时class模板成员函数'std::basic_ostream<char,std::char_traits> &std::basic_ostream<char,std::char_traits>::operator <<(int)'
triplex.cpp(22): 注意:参见函数模板实例化参考 'std::basic_ostream<char,std::char_traits> &std::basic_ostream<char,std::char_traits>::operator <<(int)' 正在编译
triplex.cpp(7):注意:请参阅参考 class 模板实例化 'std::basic_ostream<char,std::char_traits>' 正在编译
谁能给我解释一下这些是什么? 提前致谢!
这只是警告,它准确地告诉您:exception handler used, but unwind semantics are not enabled. Specify /EHsc
。
如果你进入 project properties->c/c++->Code generation->enable c++ exceptions
并将其设置为 Yes (/EHsc)
(实际上它应该是默认值),你就可以开始了。