Skip to content

Commit

Permalink
解决 demo 在 vs2022 上的编译问题. 默认将 cmake 编译设置为 utf8 模式, 否则会报错. 实际上如果想要跨平台, …
Browse files Browse the repository at this point in the history
…后续也不能再用 GBK 了。
  • Loading branch information
wysaid committed Dec 9, 2023
1 parent d0675f5 commit ac05fdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ add_custom_target(demos)
# 增加可执行目标,作为 demos 的依赖
macro(ege_add_executable_demo name source)
ege_add_executable(${name} ${source})

if (MSVC)
target_compile_options(${name} PRIVATE
/utf-8
/D_USE_MATH_DEFINES
)
endif()

set_property(TARGET ${name}
PROPERTY EXCLUDE_FROM_ALL true)
add_dependencies(demos ${DEMO_NAME})
Expand Down
4 changes: 4 additions & 0 deletions demo/egejulia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* (编译后改为scr后缀使用)
*/

#ifdef _CRT_FUNCTIONS_REQUIRED
#undef _CRT_FUNCTIONS_REQUIRED /// 解决在高版本 visual studio中, log2 与系统定义的版本冲突的问题
#endif

#include "graphics.h"
#include <stdio.h>
#include <stdlib.h>
Expand Down

0 comments on commit ac05fdc

Please sign in to comment.