Sunday, September 17, 2017

Digest for comp.lang.c++@googlegroups.com - 4 updates in 1 topic

pedro1492@lycos.com: Sep 16 07:32PM -0700

I have some package, that builds find with old gcc/g++ 4.4 and 4.8 (working with
enterprise linux). I had a go with a distro that has newer gcc 7.2
All went fine except a heap of errors related to stl_algobase.hh such as:
 
/usr/include/c++/7/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
 
the chain of includes leading up to this is:
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
from /usr/include/c++/7/ios:40,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
 
so something has changed since the ancient versions I used before.
 
Trying various compiler flags -std=c++98 or gnu++98 helps not.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Sep 17 07:35AM +0200

> from /usr/include/c++/7/iostream:39,
 
> so something has changed since the ancient versions I used before.
 
> Trying various compiler flags -std=c++98 or gnu++98 helps not.
 
In C++14 §25.4.7 there are the following overloads of `min`:
 
template<class T> constexpr const T& min(const T& a, const T& b);
 
template<class T, class Compare>
constexpr const T& min(const T& a, const T& b, Compare comp);
 
template<class T>
constexpr T min(initializer_list<T> t);
 
template<class T, class Compare>
constexpr T min(initializer_list<T> t, Compare comp);
 
`min` is not a macro in standard C++.
 
Maybe that fact can guide you towards resolving this?
 
 
Cheers & hth.,
 
- Alf
Jorgen Grahn <grahn+nntp@snipabacken.se>: Sep 17 05:43AM

> from /usr/include/c++/7/iostream:39,
 
> so something has changed since the ancient versions I used before.
 
> Trying various compiler flags -std=c++98 or gnu++98 helps not.
 
Probably a case of a new compiler revealing broken code.
 
Check if your package or some library it uses defines a macro called
'min'. As you can see when you think about it, the code in
stl_algobase.h would become very unhappy if that was the case.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
"Öö Tiib" <ootiib@hot.ee>: Sep 17 11:30AM -0700

> from /usr/include/c++/7/iostream:39,
 
> so something has changed since the ancient versions I used before.
 
> Trying various compiler flags -std=c++98 or gnu++98 helps not.
 
Somehow the authors of your package have managed to do same stupid
thing that Microsoft did. Microsoft did so that the windows.h declared
macros named "min" and "max" and so standard library did not work.
 
Solution on case of windows was that who did not want non-working
standard library had to define NOMINMAX then windows.h did not
define macros min and max. However Microsoft's own headers like
gdiplus.h used those min and max macros and so more clever solution
was needed.

Perhaps just search for "#define min" in your code base and replace
it with "#define never_use_names_from_standard_library_for_macros_min".
Same do with "max" of yours.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: