Discussion:
gcc3.4.6: std::min and std::max
BG / Galaxy
2006-11-16 08:53:04 UTC
Permalink
Hello,

I recently upgraded my system from Solaris2.5.1/gcc3.3.2 to
Solaris7/gcc3.4.6.
When recompiling my project, I often get errors in gcc files complaining
about lines using std::min or std::max,
ie:

In file included from
/usr/local/lib/gcc/sparc-sun-solaris2.7/3.4.6/../../../../include/c++/3.4.6/
vector:72,
from
/export/home/godev/galaxy_std_libraries/include/gerrormgr.h:32,
from
/export/home/godev/galaxy_std_libraries/include/gatdftostdf.h:45,
from import_all.h:4,
from filter_dialog.cpp:20:
/usr/local/lib/gcc/sparc-sun-solaris2.7/3.4.6/../../../../include/c++/3.4.6/
bits/stl_bvector.h: In member function `void std::vector<bool,
_Alloc>::_M_insert_range(std::_Bit_iterator, _ForwardIterator,
_ForwardIterator, std::forward_iterator_tag)':
/usr/local/lib/gcc/sparc-sun-solaris2.7/3.4.6/../../../../include/c++/3.4.6/
bits/stl_bvector.h:522: error: expected unqualified-id before '(' token
/usr/local/lib/gcc/sparc-sun-solaris2.7/3.4.6/../../../../include/c++/3.4.6/
bits/stl_bvector.h: In member function `void std::vector<bool,
_Alloc>::_M_fill_insert(std::_Bit_iterator, size_t, bool)':
/usr/local/lib/gcc/sparc-sun-solaris2.7/3.4.6/../../../../include/c++/3.4.6/
bits/stl_bvector.h:823: error: expected unqualified-id before '(' token

line 522 is:

const size_type __len = size() + std::max(size(), __n);

line 823 is:

const size_type __len = size() + std::max(size(), __n);


I get the same type of error for fstream.tcc, vector.tcc...
If I remove the std:: namespace specifier, the error disappears, but I'm not
so sure if it is correct.

I downloaded and installed a compiled package of gcc from
www.sunfreeware.com.

Any suggestions?

Thanks,
Bernard
John Love-Jensen
2006-11-16 12:41:03 UTC
Permalink
Hi Bernard,

Try putting this in the code just before line 522 and line 823:

#ifdef max
#error "BZZZT: max was defined as an evil macro function"
#endif

...or use this band-aid instead before line 522 and line 823...

#ifdef max
#undef max
#define max max
#endif

HTH,
--Eljay

Loading...