Namespace collision?

Okay, I'm getting errors when I try to compile my program. I think I know what the problem is, but I'm not sure what is the best way to fix it. The program is using the pari/gp number theory library. Problem is, when I include both pari.h and algorithm.h from STL, I get errors:

make -k
g++ -c -I. -I/opt/local/include -I/usr/local/include -g algebraic.cc
g++ -c -I. -I/opt/local/include -I/usr/local/include -g hello.cc
In file included from /usr/include/c++/4.3/bits/stl_algo.h:66,
from /usr/include/c++/4.3/algorithm:67,
from stableform.h:10,
from hello.cc:6:
/usr/include/c++/4.3/bits/algorithmfwd.h:248:41: error: macro "max" passed 3 arguments, but takes just 2
/usr/include/c++/4.3/bits/algorithmfwd.h:259:41: error: macro "min" passed 3 arguments, but takes just 2

My guess is pari has already defined max, and this is conflicting with algorithm. Does this sound correct, and is there a smart C++ way to get around this without messing around with the libraries themselves? I already tried switching the order which they were included since this helped similar problems in the past, but that didn't work. Anyway it is a hack and there must be a better solution. The program also compiles and works as is on a different computer...
I would #undef (or maybe it was #undefine, I'm not sure) max and min and copy the one you need from the header.

This is what happens when you don't give suffixes to identifiers.
Thanks for the reply. I haven't tried it yet, but quick question: Does it sound like a correct statement of the problem? The pari library is defining the functions max and min in the global namespace, which is then a problem when the STL library tries to uses these names for its internal functions. If this is the problem, then is there a way to get the pari library to define stuff only in its own namespace? I tried
1
2
3
4
namespace pari
{
#include "pari/pari.h"
}

but it does not make any difference.
No. max and min are macros, not functions. The compiler is obviously not confusing them with the STL functions, since it clearly says they're macros.

And no, that never works.
OK, that makes sense. I think I understand your solution now too. I'm self-taught as far as programing goes, so easily confused.

Anyway, I got my trick to work. Seems if pari.h is always included last there is no problem. Thanks for your help!
Topic archived. No new replies allowed.