Microos Microos - 1 year ago 95
C++ Question

gcc-6 compile error: expected '(' before 'isnan'

I encountered a weird error that says:

spams/linalg/linalg.h: In member function 'void Matrix<T>::eigLargestSymApprox(const Vector<T>&, Vector<T>&) const':
spams/linalg/linalg.h:1681:10: error: expected '(' before 'isnan'

if isnan(lambda) {

And I then go to check the code where the complier refer to:

if isnan(lambda) {
std::cerr << "eigLargestSymApprox failed" << std::endl;

It seems the problem of the function call of

Do you have any idea about it?

Answer Source

The expression in the if needs to be enclosed in parentheses:

if (std::isnan(lambda))

will fix it. Note that std::isnan was introduced in the C++11 standard.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download