Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Problems with gcc 3.4.6 limit template on RHE 4?

Tony_Garratt
Beginner
381 Views

I am using Intel Fortran and C++ 11.1 update 5 on RHE 4.1 and getting a problem with the limit template (we had no such problems when compiling the same code on RHE 3 andgcc 320 and Intel 10.1). I wondered if anyone has run into this problem before and might haveany tips or suggestions please?

/usr/include/c++/3.4.6/limits(292): error #54: too few arguments in macro invocation

static _Tp max() throw() { return static_cast(0); }

^

/usr/include/c++/3.4.6/limits(292): error: expected an identifier

static _Tp max() throw() { return static_cast(0); }

0 Kudos
5 Replies
Ron_Green
Moderator
381 Views

Since this is strictly a C++ question, I'll transfer this to our C++ Forum to see if they have an answer.

ron

0 Kudos
Tony_Garratt
Beginner
381 Views

Thanks Ron!

0 Kudos
Judith_W_Intel
Employee
381 Views
My guess is you have a #define max(...) somewhere in your headers that you've included before limits so it's trying to expand the max identifier but there are no arguments. You could probably fix this by moving the #include of limits before the include of your header.
0 Kudos
TimP
Honored Contributor III
381 Views

Besides the traditional Windows

#undef max

(which seems a likely solution, given the unexpected reference to a macro)

I've had C++ apps where changing max to std::max was required, because the application got a different max from another namespace. For example, Ct has exhibited such conflicts. I'd like to see that one resolved by experts, but I guess we can't count on that.

0 Kudos
Tony_Garratt
Beginner
381 Views

Thank you! That was it - we had re-defined max ourselves. Now you point it out, its fairly obvious :-)

I wonderhow many others have run into this - seems a bit bad that gcc defines max itself, since defining your own max is fairly common for C++ programmers.....

Thanks!

Tony

0 Kudos
Reply