Menu

#1752 Fails to compile: error: ‘isnan’ was not declared in this scope

None
closed
nobody
None
1
2016-05-01
2016-05-01
Anonymous
No
pdfviewer/PDFDocument.cpp: In member function void PDFWidget::goToPageRelativePosition(int, float, float):
pdfviewer/PDFDocument.cpp:968:18: error: isnan was not declared in this scope
  if (isnan(xinpdf)) xinpdf = 0;
                  ^
pdfviewer/PDFDocument.cpp:968:18: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/random:38:0,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/bits/stl_algo.h:66,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/algorithm:62,
                 from /usr/include/qt5/QtCore/qglobal.h:85,
                 from /usr/include/qt5/QtCore/qnamespace.h:37,
                 from /usr/include/qt5/QtCore/qobjectdefs.h:41,
                 from /usr/include/qt5/QtCore/qobject.h:40,
                 from /usr/include/qt5/QtCore/QObject:1,
                 from ./modifiedQObject.h:44,
                 from ./mostQtHeaders.h:12,
                 from pdfviewer/PDFDocument.h:28,
                 from pdfviewer/PDFDocument.cpp:24:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/cmath:641:5: note:   std::isnan
     isnan(_Tp __x)
     ^
pdfviewer/PDFDocument.cpp:970:18: error: isnan was not declared in this scope
  if (isnan(yinpdf)) yinpdf = 0;
                  ^
pdfviewer/PDFDocument.cpp:970:18: note: suggested alternative:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/random:38:0,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/bits/stl_algo.h:66,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/algorithm:62,
                 from /usr/include/qt5/QtCore/qglobal.h:85,
                 from /usr/include/qt5/QtCore/qnamespace.h:37,
                 from /usr/include/qt5/QtCore/qobjectdefs.h:41,
                 from /usr/include/qt5/QtCore/qobject.h:40,
                 from /usr/include/qt5/QtCore/QObject:1,
                 from ./modifiedQObject.h:44,
                 from ./mostQtHeaders.h:12,
                 from pdfviewer/PDFDocument.h:28,
                 from pdfviewer/PDFDocument.cpp:24:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/cmath:641:5: note:   std::isnan
     isnan(_Tp __x)
     ^
pdfviewer/PDFDocument.cpp:975:19: error: isnan was not declared in this scope
  if (!isnan(xinpdf))

Original gentoo bug report:
https://bugs.gentoo.org/show_bug.cgi?id=581520

Discussion

  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01

    well, isnan is taken from math.h, which is included in the code.
    It compiles fine everywhere (see https://build.opensuse.org/package/show/home:jsundermeyer/)
    So I would say, the ball is on your side of the field...

     
  • Tim Hoffmann

    Tim Hoffmann - 2016-05-01

    Happens under Kubuntu 16.04 as well.

    This is a collision between math.h and cmath imported from these dependencies:

    In file included from /usr/include/c++/5/random:38:0,
                     from /usr/include/c++/5/bits/stl_algo.h:66,
                     from /usr/include/c++/5/algorithm:62,
                     from ../../../Qt/5.6/gcc_64/include/QtCore/qglobal.h:85,
                     from ../texstudio-hg/modifiedQObject.h:5,
                     from ../texstudio-hg/mostQtHeaders.h:12,
                     from ../texstudio-hg/pdfviewer/PDFDocument.h:28,
                     from ../texstudio-hg/pdfviewer/PDFDocument.cpp:24:
    

    @Jan, Benito: Do you see any problems if we switch from math.h to cmath and use std::isnan?

     
  • Franz Fellner

    Franz Fellner - 2016-05-01

    It is not an issue on my side. Just open the cmath header and find "#undef isnan".
    As you can see on the compiler output (comes from gcc-4.9.3, btw.) "random" includes cmath, random get's included by indirectly by Qt. And that finally #undefs everything from math.h which leads to this issue.
    I tried to move the math.h include to the end of the includes which did NOT fix this issue. As this is a c++-project the proper solution of course is to use the corresponding c++-header, which is <cmath>.</cmath>

     
  • Benito van der Zander

    qIsNan?
    
     
  • Tim Hoffmann

    Tim Hoffmann - 2016-05-01

    fixed: hg 5998 (91a3b80d1379)

     
  • Tim Hoffmann

    Tim Hoffmann - 2016-05-01
    • status: open --> fixed
    • Group: -->
     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01

    It is rather a mystery that cmath works, as isnan is officially only supported with c++11, which I doubt is already activated with Centos-6, but it compiles ...
    Furthmore math.h is perfectly fine, so why it does not work any more on gentoo and kubuntu 16.04, but with lubuntu&ubuntu 16.04 is rather strange.

     
  • Tim Hoffmann

    Tim Hoffmann - 2016-05-01

    As suggested by Benito, It would probably be the safest option not to use cmath or math.h at all but resort to Qt functions whenever possible.

    -> hg 5999 (5b16f01c3b60)

     

    Last edit: Tim Hoffmann 2016-05-01
  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01

    Does not compile with Qt4.

    toolwidgets.cpp:1:18: fatal error: QtMath: No such file or directory
     #include <QtMath>
    
     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01
    • status: fixed --> open
     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01

    I would suggest to go back to the cmath solution as that compiles on all our supported linux platforms as tested on OBS.

     
  • Tim Hoffmann

    Tim Hoffmann - 2016-05-01

    @Jan: Please try the latest commit. I think it should work that way (though I cannot test because I don't have Qt4 installed). If not, we'll go back to cmath.

     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01

    I fixed the remaining bugs

     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2016-05-01
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB