Running 'gcc' on C++ source file on Linux gives “cc1plus: out of memory allocating …” error message

前端 未结 2 1567
野的像风
野的像风 2020-12-04 01:20

I encountered a puzzling problem when compiling a C++ source file using \'gcc\' on Ubuntu. Having solved the problem I would like to publish it here to save others the head

2条回答
  •  生来不讨喜
    2020-12-04 02:04

    It turns out I had saved the C++ source file as a UTF-16 Unicode-encoded file, complete with leading Unicode Byte Order Mark (BOM) bytes at the beginning of the file. The file was saved as UTF-16 on a Windows system, committed to a version control system, then checked out to Linux. gcc does support Unicode encoded as UTF-8, but not Unicode encoded as UTF-16.

    The solution was to convert the source file back to a standard, non-Unicode encoding.

提交回复
热议问题