本文介绍了如果存在两个#defines,如何强制编译错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个可以用#defines编译的项目。 说: - #define firstdef #define seconddef 如果没有定义或只有一个定义,则一切正常。如果两个 #defines都存在,我会在代码中添加一个自检来防止编译。这可能吗? 解决方案 #if defined(firstdef)&&已定义(seconddef) #error"无法定义firstdef和seconddef" #endif 文章< 11 ********************* @ n39g2000hsh.googlegroups。 com>, Eliot< eb*@hotmail.comwrote: #if defined(firstdef)&&定义(seconddef) #error不能定义两个 #endif - Richard - 在一些字母表中需要考虑多达32个字符 - X3.4,1963。 #if defined(fistdef)&&定义(secondef) #error不要这样做! #endif Roberto Waltman [请回复小组, 返回地址无效] I have a project which may be compiled with some #defines.Say:-#define firstdef#define seconddefIf no defines are present or only one is present all is OK. I wouldlike to add a self check to the code that prevents compilation if both#defines are present. Is this possible? 解决方案#if defined(firstdef) && defined(seconddef)#error "Cannot define both firstdef and seconddef"#endif#if defined(firstdef) && defined(seconddef)#error Mustn''t define both#endif-- Richard--"Consideration shall be given to the need for as many as 32 charactersin some alphabets" - X3.4, 1963.#if defined(fistdef) && defined(secondef)#error Don''t do this!#endifRoberto Waltman[ Please reply to the group,return address is invalid ] 这篇关于如果存在两个#defines,如何强制编译错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-14 08:36