[英]Predefined C++ Types (compiler internal) Not Found error
我试图编写一个井字游戏只是为了好玩,当我尝试调试应用程序时遇到了这个错误。 错误发生在第 23 行,即多维 std::array 声明。 我找不到有关该主题的任何材料或想出自己的解决方案。 该错误显示在 VS 2019 的“未找到源”选项卡中,看起来不像是正常错误,这是文本:“未找到预定义的 C++ 类型(编译器内部)您需要找到预定义的 C++ 类型(编译器内部)查看当前调用堆栈帧的来源。”
#include <io.h>
#include <fcntl.h>
#include <iostream>
#include <algorithm>
#include <array>
#include <string>
class tic_tac_toe
{
private:
enum class values
{
X,
O,
max_values
};
struct square_data
{
std::string code{};
values value{};
};
std::array<std::array <square_data, 3>, 3> board{};
public:
tic_tac_toe()
{
for (int a{ 0 }; a < 3; ++a)
{
for (int b{ 0 }; b < 3; ++b) {
switch (a)
{
case 0:
board.at(a).at(b).code = "A";
board.at(a).at(b).value = values::max_values;
break;
case 1:
board.at(a).at(b).code = "B";
board.at(a).at(b).value = values::max_values;
break;
case 2:
board.at(a).at(b).code = "C";
board.at(a).at(b).value = values::max_values;
break;
default:
std::cout << "initializer failed\n"; //shouldn't happen
}
board.at(a).at(b).code.append(std::to_string((b + 1)));
}
}
print_grid();
}
void print_code(square_data square)
{
switch (square.value)
{
case values::X:
std::wcout << L"X";
break;
case values::O:
std::wcout << L"O";
break;
default:
std::wcout << L" ";
}
}
void print_grid()
{
fflush(stdout);
int previous{ _setmode(_fileno(stdout), _O_U16TEXT) }; //print unicode
for (int a{ 0 }; a < 3; ++a)
{
switch (a)
{
case 0:
std::wcout << L"\n┌───┬───┬───┐\n│ ";
break;
case 1:
std::wcout << L"\n├───┼───┼───┤\n│ ";
break;
case 2:
std::wcout << L"\n├───┼───┼───┤\n│ ";
break;
default:
std::cout << "printer failed\n";
}
for (int b{ 0 }; b < 3; ++b) {
print_code(board.at(a).at(b));
std::wcout << L" │ ";
}
}
std::wcout << L"\n└───┴───┴───┘\n";
fflush(stdout);
_setmode(_fileno(stdout), previous); //for switching back to narrow output
}
};
int main()
{
tic_tac_toe game{};
return 0;
}
这是VS的错误。 当我删除 /permissive- 时它起作用。 此问题已被报告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.