How to resolve warning: multi-character character constant in Linux C++

后端 未结 2 1877
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 04:49
#ifdef WIN32
#   define TARGET_OS \'W_NT\'

I am getting C++ warning in Linux multi-character character constant. at the below line. How to resolve this

2条回答
  •  一个人的身影
    2021-01-29 05:14

    Don't define preprocessor constants as strings or chars when testing them in #if. Perhaps coding

    #if TARGET_OS_IS_WIN_NT
       /* do something for Windows NT */
    #endif
    
    #if TARGET_OS_IS_LINUX
       /* do something for Linux */
    #endif
    

    Better yet, consider using multi-system libraries like e.g. Qt -they did all the boring job of handling system specific things and provide you with a nice common API.

提交回复
热议问题