Sanket Lad
Sanket Lad

Reputation: 351

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 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

Upvotes: 2

Views: 2143

Answers (4)

James Kanze
James Kanze

Reputation: 153919

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).

Upvotes: 2

Heisenbug
Heisenbug

Reputation: 39164

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.

Upvotes: 0

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.

Upvotes: 3

Lindydancer
Lindydancer

Reputation: 26094

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.

Upvotes: 0

Related Questions