c++ - 巨大的初始化列表,如何修复 "fatal error C1060: compiler is out of heap space"

标签 c++ visual-studio-2015 heap-memory

我正在尝试编译一个简单的 C++ 文件,它可以:

static const unsigned char content[] = 
        {
              // 29MB of data written as "0x1E, 0x83, 0x3E, 0x86, 0xC8, 0x80, ...". 10 values per line
        };

要编译的文件有近 3M 行,大约 200Mo

这是资源管理系统的输出,尝试在我的二进制文件中嵌入一个 29Mo 资源文件(假设它是一个视频文件)以供以后在运行时使用。

当我编译时,VS2015 报告:

fatal error C1060: compiler is out of heap space

有没有其他选择(使用 static const unsigned char 之外的东西)?使文件的行数减少但每行字符数增加? ...

注意:我尝试了/Zm1000 选项,但没有成功。

最佳答案

根据 MSDN documentation关于主题:

Eliminate unnecessary global variables, for example, by allocating memory dynamically instead of declaring a large array.

Split the current file into smaller files.

这两个问题你都应该修复。

关于c++ - 巨大的初始化列表,如何修复 "fatal error C1060: compiler is out of heap space",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51323518/

相关文章:

c++ - 在函数中使用非静态值作为默认参数

C++:将std::unique_ptr(仅移动类型)右值作为参数传递时复制省略

c# - 在 VS2015 上对 UWP 应用程序使用 xUnit 测试

C++ 类数组内存重新分配

c++ - 链接列表、结构和类

visual-studio-2015 - 'ConnectedServicesPackages' - Visual Studio 2015

syntax-highlighting - 哪个 "Display item"类型是代码? (用于更改颜色语法突出显示)

c - 我应该把大数组放在栈上还是堆上?

java - 是否可以查看对象使用了多少堆?

c++ - 将 unsigned char 转换为字符串,然后再转换为 unsigned char