所需库中相同#define宏的多个定义 [英] Multiple Definitions of Same #define Macro in Required Libraries
问题描述
我包括的两个库在各自的.h文件中共享一个宏的相同定义。
#定义MAX<一些值> //文件中MAX的第一个定义
#define MAX< some other value> //不同文件中的MAX的第二个定义
并在编译中得到
... / httpd.h:43:1:警告: MAX重新定义了
和
... / opencv2 / core / types_c.h:272:1:警告:这是先前定义的位置
我已经检查每个标头,并使用#include防护措施。标记)?
这种情况的唯一坏处是对 Two of the libraries I am including share the same definition of a macro in each of their respective .h files. and in compilation I get and I've checked each of these headers, and they have the #include guards. What is the best way to fix this error (failing that, suppress the warning with a different -W flag)? The only bad part about this situation is dependencies on 这篇关于所需库中相同#define宏的多个定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! MAX $ c $的依赖c>在您的代码中(如果有)。如果没有,在两个
#include
之间添加一个 #undef MAX
可能是最快的解决方法。如果您确实依赖于 MAX
,则可能需要找出哪一个(我想这是最后一个:-)并做一些适当的事情。 / p> #define MAX <some value> //first definition of MAX in a file
#define MAX <some other value> //second definition of MAX in a *different* file
.../httpd.h:43:1: warning: "MAX" redefined
.../opencv2/core/types_c.h:272:1: warning: this is the location of the previous definition
MAX
in your code, if any. If you don't have any, adding an #undef MAX
between the two #include
s is probably the fastest fix. If you do have dependencies on MAX
you might need to figure out which one (I guess it's the last :-) and do something appropriate.