How to diagnose g ++ error "cc1plus.exe: allocates 838860800 bytes from memory" in a project with moderate size?

I am trying to port my C ++ library to g ++ using a rudimentary makefile (it compiles well in Visual Studio). The part I'm trying to compile now measures about 45,000 lines of code.

The library itself compiles in order, but when I try to include it in the console's iterface application, the compiler resets the following message and nothing else:

cc1plus.exe: out of memory allocating 838860800 bytes 

This happens when I include the main title of the project (which is generated by the machine and not tied to a repo, see here in Gist ).

I realized that this is because the title is too large, but I noticed that other projects have comprehensive titles like this and do not suffer from these problems. I tried to remove all unnecessary things (about 1/3, the rest was necessary to compile the application) from the header, and the problem continued. I also noticed that the number in the error message did not change at all, so I believe that there is some singular problem causing the error, and not caused by the explicit amount of code.

Using a regular template is very small, but the code that I compile does not look any great.

I am using g ++ 4.8.1 under mingw32 on Windows 8.1 x64 with 16 GB of RAM. The code is compiled using -std=c++98 .

How to find the code causing this problem? g ++ does not provide me with any diagnostic information to suggest a reason, even with the -v switch ( this is what it returns ).

+6
source share
1 answer

This happens when you try to compile a UTF-16 encoded file saved on Windows using gcc. Change the encoding of your sources to UTF-8. See related CPP documentation .

+10
source

Source: https://habr.com/ru/post/984099/


All Articles