在windows 10 上用ninja编译gn构建工具时编译器遇到C4819

问题发现经过
平台:Windows10 LTSC,VS2017,python3.9

F:\program\git> git clone https://bitbucket.org/chromiumembedded/cef/src/master/ gn
F:\program\git> cd gn
F:\program\git\gn> python build/gen.py
F:\program\git\gn> vcvarsall x64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.21
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
F:\program\git\gn> ninja -C out
[51/284] CXX src/gn/command_help.obj
FAILED: src/gn/command_help.obj
ninja -t msvc -- cl.exe /nologo /showIncludes /FC -I..\src -I. /O2 /DNDEBUG /Zc:inline /DNOMINMAX /DUNICODE /DWIN32_LEAN_AND_MEAN /DWINVER=0x0A00 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_UNICODE /D_WIN32_WINNT=0x0A00 /FS /W4 /WX /Zi /wd4099 /wd4100 /wd4127 /wd4244 /wd4267 /wd4505 /wd4838 /wd4996 /std:c++17 /GR- /D_HAS_EXCEPTIONS=0 /c ..\src\gn\command_help.cc /Fosrc/gn/command_help.obj
f:\program\git\gn\src\gn\escape.h: error C2220: warning treated as error - no 'object' file generated
f:\program\git\gn\src\gn\escape.h: warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss

解决方法
修改gn/build/gen.py 第525行:
修改前

        '/wd4244',
        '/wd4267',
        '/wd4505',
        '/wd4838',
        '/wd4996',
        '/std:c++17',
        '/GR-',
        '/D_HAS_EXCEPTIONS=0',
    ])

添加一个’/wd4819’,

        '/wd4244',
        '/wd4267',
        '/wd4505',
        '/wd4838',
        '/wd4819',
        '/wd4996',
        '/std:c++17',
        '/GR-',
        '/D_HAS_EXCEPTIONS=0',
    ])

之后删除 out/src 文件,重新ninja -C out ,成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值