Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.4k views
in Technique[技术] by (71.8m points)

visual studio - macro "max" requires 2 arguments, but only 1 given

template <class T>
struct scalar_log_minimum {
public:
    typedef T value_type;
    typedef T result_type;
    static
        result_type initial_value(){
            return std::log(std::numeric_limits<result_type>::max());
    }
    static
        void update(result_type& t, const value_type& x){
            if ( (x>0) && (std::log(x)<t) ) t = std::log(x);
    }
};

i got the following error while trying to compile the above:

functional_ext.hpp:55:59: macro "max" requires 2 arguments, but only 1 given

max is not a macro, right? Then what is this error? BTW, I am using visual studio 2005

Also what is 55:59 --- 55 is the line number 59?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're including a header file somewhere that #defines max as a macro. The best solution would be to figure out where it's being defined, and inhibit it from being defined if possible. Alternatively, you could just #undef it:

#include <evil_header_which_defines_max.h>
#undef max

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...