什么是“异常处理程序状态”?

时间:2018-08-17 13:36:23

标签: c++ visual-studio exception compiler-errors try-catch

Visual Studio's error C1509说:

  

函数中的异常处理程序状态太多

我很好奇“异常处理程序状态”是什么。它声称最大状态数为: 2 15 。但是,当我运行此代码生成的文件时没有得到此错误时,该文件具有 2 15 + 1 try-catch块:

#include <fstream>
#include <iostream>

using namespace std;

int main() {
  ofstream foo{ "main.cpp" };
  const auto primer = "\tfoo = value(g);\n";

  const auto body = "\ttry{\n"
                    "\t\tcout << 13.0F / foo << endl;\n"
                    "\t}catch(...){\n"
                    "\t\tcout << \"error\\n\";\n"
                    "\t}\n";

  const auto count = (1 << 15) + 1;

  if(foo)
  {
    foo <<  "#include <iostream>\n"
            "#include <random>\n"
            "\n"
            "using namespace std;\n"
            "\nint main(){\n"
            "\tmt19937 g{ random_device()() };\n"
            "\tuniform_int_distribution<> value{ 0, 13 };\n"
            "\tauto foo = value(g);\n"
            "\n" 
        << body;

    for(auto i = 1; i < count; ++i)
    {
      foo << endl << primer << body;
    }
    foo << '}' << endl;
  }
}

那么什么是异常处理程序状态?

0 个答案:

没有答案