mardi 26 mai 2015

invalid use of qualified-name 'std::max'

I'm digging through some legacy code and came across an interesting bug. I get an error at:

#include <algorithm>
#ifndef Max
#define Max std::max
#endif

I'm compiling using -std=c++0x and I get the error:

error: invalid use of qualified-name 'std::max'

I tried a sample program that does the exact same thing and it doesn't complain. What am I missing?

UPDATE: The problem seems to be with the #ifndef statements. I commented out those and it compiles. I now have:

#include <algorithm>
#define Max std::max

compiles.

Aucun commentaire:

Enregistrer un commentaire