nightmareci / HeborisCE

Cross-platform Expansion (C.E.) and continuation of Heboris U.E. using modern technology and development approach
36 stars 5 forks source link

Building Errors C2143 and C2001 #30

Closed Sonic-TV closed 6 months ago

Sonic-TV commented 7 months ago

tried building the game from source and i got the following errors and warnings.

D:\HeborisCE\src\script\mission.c(568,35): error C2001: 常量中有换行符 [D:\HeborisCE\build\x64\build\HeborisCE.vcxproj] D:\HeborisCE\src\script\mission.c(569,3): error C2143: 语法错误: 缺少“)”(在“else”的前面) [D:\HeborisCE\build\x64\build\HeborisCE. vcxproj] D:\HeborisCE\src\script\mission.c(585,157): error C2001: 常量中有换行符 [D:\HeborisCE\build\x64\build\HeborisCE.vcxproj] D:\HeborisCE\src\script\mission.c(586,3): error C2143: 语法错误: 缺少“)”(在“if”的前面) [D:\HeborisCE\build\x64\build\HeborisCE.vc xproj]

translation of chinese: constant value has line break signs missing ")" (before "else") constant value has line break signs missing ")" (before "if")

the mission_info.c got the C2001 error as well.

Sonic-TV commented 7 months ago

some of the files got C4819 warnings. mostly the japanese texts. example of the warning:D:\HeborisCE\src\game\gamestart.c(3109,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 [D:\HeborisCE\build\x64\build\HeborisCE.vcxproj]

translation:this file has characters that cannot display in codepage 936. please save this file as unicode format to prevent data loss.

building environment: VS2022, latest compilers, Simplified Chinese Windows 11 Pro.

Sonic-TV commented 7 months ago

.\pkg\windows\pkg.bat path\to\vcpkg.cmake . build-pkg command doesn't work for build. It simply outputs nothing, and no any new folders are created.

Building using command pkg.bat . build x64.

nightmareci commented 7 months ago

some of the files got C4819 warnings. mostly the japanese texts. example of the warning:D:\HeborisCE\src\game\gamestart.c(3109,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 [D:\HeborisCE\build\x64\build\HeborisCE.vcxproj]

translation:this file has characters that cannot display in codepage 936. please save this file as unicode format to prevent data loss.

building environment: VS2022, latest compilers, Simplified Chinese Windows 11 Pro.

I think this error is occurring because your Windows installation/locale isn't UTF-8, it's codepage 936, a legacy Chinese encoding, which isn't compatible with UTF-8. Originally, the source code was Shift JIS, a Japanese text encoding, but I converted everything to UTF-8 a while ago, for better ease of use and portability.

I think you'll have to somehow get a UTF-8 locale Windows installation. Maybe the for-China version of Windows you're using doesn't support that, I don't know. I don't think this is an issue on the end of HeborisCE, it's your Windows setup.

If you're unable to change your Windows setup, I'm more or less forced to tell you "you can't build it", I'm very sorry if that's the case. The only last-resort solution I can think of in such a case would be to remove all Japanese text from every source code file, something I really don't want to do, unless everything were also translated to English in that process.

Sonic-TV commented 7 months ago

the C4819 is just a warning, so I could just ignore it while building using VS.

nightmareci commented 7 months ago

the C4819 is just a warning, so I could just ignore it while building using VS.

I still think it's a locale/UTF-8 issue, the other errors might just be a result of that, since those line numbers in mission.c are where there's UTF-8-encoded Japanese text. Another option to build it is use MSYS2, which might work.

Maybe creating a new user account on your Windows machine in English could solve the issue, then only try building there. Or use a non-Chinese version of Windows that's for sure UTF-8, like the US English version.

Sonic-TV commented 7 months ago

It finally works using MSYS2... I guess I need to find some ways to force load the code as UTF-8. Closed as solved.

Sonic-TV commented 7 months ago

seems add the following to CMakeLists.txt works with VS. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>") add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

nightmareci commented 6 months ago

seems add the following to CMakeLists.txt works with VS. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>") add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

I'll add that to the CMake build scripts soon enough. It seems that's really only needed for MSVC/Visual Studio, since every other compiler reads source code as UTF-8, MSVC might not.