std::limits compile errors with boost

Anyone has seen this?: In file included from ../include/boost/lockfree/detail/freelist.hpp:12, from ../include/boost/lockfree/queue.hpp:24, from test.cpp:2: /usr/local/powerpc-linux-gnu/include/c++/4.3.2/limits:287:22: error: macro "min" requires 2 arguments, but only 1 given Thanks

It looks like the min and max macros are defined for your project. I don't know how you do it in gcc, but in Visual Studio you define NOMINMAX to disable those. This is necessary because <limits> won't work otherwise. Best regards, M. Mueller From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of David Frank Sent: Thursday, June 12, 2014 11:34 AM To: boost-users@lists.boost.org Subject: [Boost-users] std::limits compile errors with boost Anyone has seen this?: In file included from ../include/boost/lockfree/detail/freelist.hpp:12, from ../include/boost/lockfree/queue.hpp:24, from test.cpp:2: /usr/local/powerpc-linux-gnu/include/c++/4.3.2/limits:287:22: error: macro "min" requires 2 arguments, but only 1 given Thanks

You need to ensure that *all* references to min and max are enclosed in brackets for example (std::numeric_limits<FPT>::max)(); http://www.boost.org/doc/libs/1_34_0/more/lib_guide.htm says: * Make sure your code compiles in the presence of the min() and max() macros. Some platform headers define min() and max() macros which cause some common C++ constructs to fail to compile. Some simple tricks can protect your code from inappropriate macro substitution: * If you want to call std::min() or std::max(): * If you do not require argument-dependent look-up, use (std::min)(a,b). * * If you do require argument-dependent look-up, you should: * * #include <boost/config.hpp> * Use BOOST_USING_STD_MIN(); to bring std::min() into the current scope. * Use min BOOST_PREVENT_MACRO_SUBSTITUTION (a,b); to make an argument-dependent call to min(a,b). * * If you want to call std::numeric_limits<int>::max(), use (std::numeric_limits<int>::max)() instead. * * If you want to call a min() or max() member function, instead to doing obj.min(), use (obj.min)(). * * If you want to declare or define a function or a member function named min or max, then you must use the BOOST_PREVENT_MACRO_SUBSTITUTION macro. Instead of writing int min() { return 0; } you should write int min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; } This is true regardless if the function is a free (namespace scope) function, a member function or a static member function, and it applies for the function declaration as well as for the function definition. HTH Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 01539 561830 From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Scott Mueller Sent: 12 June 2014 22:36 To: boost-users@lists.boost.org Subject: Re: [Boost-users] std::limits compile errors with boost It looks like the min and max macros are defined for your project. I don't know how you do it in gcc, but in Visual Studio you define NOMINMAX to disable those. This is necessary because <limits> won't work otherwise. Best regards, M. Mueller From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of David Frank Sent: Thursday, June 12, 2014 11:34 AM To: boost-users@lists.boost.org Subject: [Boost-users] std::limits compile errors with boost Anyone has seen this?: In file included from ../include/boost/lockfree/detail/freelist.hpp:12, from ../include/boost/lockfree/queue.hpp:24, from test.cpp:2: /usr/local/powerpc-linux-gnu/include/c++/4.3.2/limits:287:22: error: macro "min" requires 2 arguments, but only 1 given Thanks

On 13 June 2014 09:30, Paul A. Bristow <pbristow@hetp.u-net.com> wrote:
You need to ensure that *all* references to min and max are enclosed in brackets for example
The error was in a standard header (limits) so that isn't really possible. To understand the issue we need a minimal example of code which triggers this error, so that we can find out where the min macro was defined. If it's specific to g++ 4.3 or powerpc linux, it might be tricky as neither is widely used, but maybe someone might know something.
participants (4)
-
Daniel James
-
David Frank
-
Paul A. Bristow
-
Scott Mueller