宏中的编译错误 [英] compilation error in macro

查看:78
本文介绍了宏中的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了jsvm软件,并且在编译时遇到很多错误.其中很少如下.

I have downloaded jsvm software, and I am getting many errors while compiling. Few of them is as follows.

/usr/include/c++/4.3/bits/algorithmfwd.h:248:41: error: macro "max" passed 3 arguments, but takes just 2

并且文件algorithmfwd.h如下

And the file algorithmfwd.h is as follows

 template<typename _Tp>
const _Tp&
min(const _Tp&, const _Tp&);
template<typename _Tp, typename _Compare>
const _Tp&
min(const _Tp&, const _Tp&, _Compare);

//min_element

// min_element

推荐答案

在某个地方,您定义了一个宏 max ,如果您定义了该宏,则该宏是不允许的包括标准库中的所有标头(其中包含一组重载了名为 max 的函数).您必须找出这在哪里定义了宏,然后将其删除.两种直接的可能性来了要记住:

Somewhere, you have defined a macro max, which is not allowed if you include any headers from the standard library (which has a set of overloaded functions named max). You'll have to find out where this macro is defined, and get rid of it. Two immediate possibilities come to mind:

  • 您已在其中一个标头中将其定义为宏.摆脱它.
  • 微软同时定义(或定义—我没有检查VC10)"min"和"max"作为其标头之一中的宏.将/DNOMINMAX 添加到您的编译器选项可消除这种情况.
  • 您无法控制的其他库已经定义了它.包裹这个私有标头中的库标头,其中包括库标头,然后做:
  • You've defined it as a macro in one of your headers. Get rid of it.
  • Microsoft defines (or defined—I've not check VC10) both `min` and `max` as macros in one of its headers. Add /DNOMINMAX to your compiler options to suppress this.
  • Some other library you can't control has defined it. Wrap this libraries headers in private headers, which include the library header, then do:

    #undef min
    #undef max

使用这些包装程序,而不是给您的库头文件(以及向图书馆提供者施压以更正此问题).

Use these wrappers instead of the library headers you were given (and pressure the library provider to correct this).

这篇关于宏中的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆