Portability of #warning preprocessor directive

前端 未结 6 1660
孤独总比滥情好
孤独总比滥情好 2020-11-29 10:47

I know that the #warning directive is not standard C/C++, but several compilers support it, including gcc/g++. But for those that don\'t support it, will t

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 11:19

    You are likely to get at least an unrecognized directive warning from compilers that don't recognize #warning, even if the code block is not included in your compilation. That might or might not be treated as an error - the compiler could legitimately treat it as an error, but many would be more lax.

    Are you aware of (can you name) a compiler other than GCC/G++ that provides #warning? [Edited: Sun Solaris 10 (Sparc) and the Studio 11 C/C++ compilers both accept #warning.]

提交回复
热议问题