开发者

compilation error in macro

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

And the file algorithmfwd.h is a开发者_如何学Cs 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


The error is quite explicit:

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

Before inclusion of that particular header, you have defined a macro max that takes 3 arguments. Macros are evil in that they are applied everywhere that the identifier appears. Review where in the code you are defining that macro and remove it, or at the very least change it into upper case (common convention for macros) so that it does not get expanded in all other headers.


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:

  • 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 appears as, in addition to the functions in algorithmfwd.h have a preprocessor-style macro also named max. Try to find whoever is defining this and avoid include that header files, or use #undef max if all else fail.


You are not showing the max macro. Anyway seems that you are trying to use a macro with one more parameter than what it is expecting.

I am getting many errors while compiling

Try to solve your errors in order, because one mistake can influence the next.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜