How to define UNICODE for mingw, if use CMAKE as building system

六月ゝ 毕业季﹏ 提交于 2021-01-22 12:01:37

问题


Good day, i build my Qt project with Cmake build system on windows platform, but if i add line in cmake file:

add_definitions("-DUNICODE -D_UNICODE")
definition of UNICODE not working(MINGW), this work properly only if i build my project with MSVC compiler. After some times i found workaround How do I define a variable when I call CMake, so that qtcreator knows it is defined?, this solution work but if i use native WINAPI functions such as CreateFile i get the compile error, because compiler chose CreateFileA but i use w_char and i would like to use CreateFileW, this is because the definition of macro UNICODE appears before than i include my confugure file.How can i define UNICODE macro in cmakefile?

回答1:


Have you tried (note the lack of quotes):

add_definitions(-DUNICODE -D_UNICODE)


来源:https://stackoverflow.com/questions/12129266/how-to-define-unicode-for-mingw-if-use-cmake-as-building-system

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!