Re: Fix compile error ‘isnan’ was not declared in this scope (issue 2022793002 by phajdan.jr@chromium.org)

740 views
Skip to first unread message

phajd...@chromium.org

unread,
May 30, 2016, 11:02:52 AM5/30/16
to the...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
Reviewers: Lei Zhang, jochen
CL: https://codereview.chromium.org/2022793002/

Message:
This is the full compile error I was getting:

FAILED:
obj/third_party/pdfium/xfa/fxbarcode/qrcode/xfa.BC_QRFinderPatternFinder.o
x86_64-pc-linux-gnu-g++ -MMD -MF
obj/third_party/pdfium/xfa/fxbarcode/qrcode/xfa.BC_QRFinderPatternFinder.o.d
-DPDF_ENABLE_XFA -DV8_DEPRECATION_WARNINGS -D_FILE_OFFSET_BITS=64 -DDISABLE_NACL
-DCHROMIUM_BUILD -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_PANGO=1
-DUSE_CAIRO=1 -DUSE_DEFAULT_RENDER_THEME=1 -DUSE_LIBJPEG_TURBO=1 -DUSE_X11=1
-DUSE_CLIPBOARD_AURAX11=1 -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1
-DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_NOTIFICATIONS
-DENABLE_TOPCHROME_MD=1 -DUSE_UDEV -DFIELDTRIAL_TESTING_ENABLED
-DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PDF=1 -DENABLE_PLUGINS=1
-DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_PRINTING=1
-DENABLE_BASIC_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1
-DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_MDNS=1
-DENABLE_SERVICE_DISCOVERY=1 -DENABLE_HANGOUT_SERVICES_EXTENSION=1
-DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD
-DSAFE_BROWSING_DB_LOCAL -DFT2_BUILD_LIBRARY -DUSE_LIBPCI=1 -DUSE_GLIB=1
-DUSE_NSS_CERTS=1 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -Igen
-I../.. -I../../third_party/pdfium
-I../../third_party/pdfium/third_party/freetype/include
-I../../third_party/pdfium/third_party/freetype/include/freetype -I../../v8
-I../../v8/include -fstack-protector --param=ssp-buffer-size=4 -pthread
-fno-strict-aliasing -Wno-extra -Wno-unused-parameter
-Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC
-Wno-unused-local-typedefs -m64 -march=x86-64 -O2 -fno-ident -fdata-sections
-ffunction-sections -funwind-tables -O2 -pipe -fno-exceptions -fno-rtti
-fno-threadsafe-statics -fvisibility-inlines-hidden -Wno-deprecated -std=gnu++11
-Wno-narrowing -c
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp -o
obj/third_party/pdfium/xfa/fxbarcode/qrcode/xfa.BC_QRFinderPatternFinder.o
In file included from
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp:32:0:
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp: In
member function ‘FX_BOOL CBC_QRFinderPatternFinder::HandlePossibleCenter(const
CFX_Int32Array&, int32_t, int32_t)’:
../../third_party/pdfium/xfa/fxbarcode/utils.h:34:31: error: ‘isnan’ was not
declared in this scope
#define FXSYS_isnan(x) isnan(x)
^
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp:374:8:
note: in expansion of macro ‘FXSYS_isnan’
if (!FXSYS_isnan(centerI)) {
^
../../third_party/pdfium/xfa/fxbarcode/utils.h:34:31: note: suggested
alternative:
#define FXSYS_isnan(x) isnan(x)
^
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp:374:8:
note: in expansion of macro ‘FXSYS_isnan’
if (!FXSYS_isnan(centerI)) {
^
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 ../../third_party/pdfium/core/fxcrt/include/fx_basic.h:10,
from
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h:10,
from
../../third_party/pdfium/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp:23:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/cmath:641:5: note:
‘std::isnan’
isnan(_Tp __x)
^


Description:
Fix compile error ‘isnan’ was not declared in this scope

BUG=none

Base URL: https://pdfium.googlesource.com/pdfium.git@master

Affected files (+2, -4 lines):
M xfa/fxbarcode/utils.h


Index: xfa/fxbarcode/utils.h
diff --git a/xfa/fxbarcode/utils.h b/xfa/fxbarcode/utils.h
index ca2f3214c0d38c7f2da92955bed5f09c3b40309d..dadf34859d6ff31a5bcc5375837a3418cbb5cc09 100644
--- a/xfa/fxbarcode/utils.h
+++ b/xfa/fxbarcode/utils.h
@@ -26,12 +26,10 @@ void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba);
#endif
#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
#define FXSYS_isnan(x) _isnan(x)
-#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_)
+#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || \
+ _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_)
#include <cmath>
#define FXSYS_isnan(x) std::isnan(x)
-#elif(_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_)
-#include <math.h>
-#define FXSYS_isnan(x) isnan(x)
#endif
#if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
#define FXSYS_nan() (std::numeric_limits<float>::quiet_NaN())


the...@chromium.org

unread,
May 30, 2016, 3:32:30 PM5/30/16
to phajd...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
What's the build environment where this is failing? Does this sample program
work?

----
#include <math.h>
int main() { return isnan(5) ? 1 : 0; }
---


https://codereview.chromium.org/2022793002/

joc...@chromium.org

unread,
May 30, 2016, 3:38:11 PM5/30/16
to phajd...@chromium.org, the...@chromium.org, pdfium-...@googlegroups.com
On 2016/05/30 at 19:32:30, thestig wrote:
> What's the build environment where this is failing? Does this sample program
work?
>
> ----
> #include <math.h>
> int main() { return isnan(5) ? 1 : 0; }
> ---

Why not use std::isnan everywhere?

https://codereview.chromium.org/2022793002/

the...@chromium.org

unread,
May 30, 2016, 3:56:32 PM5/30/16
to phajd...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
On 2016/05/30 19:38:11, jochen wrote:
> Why not use std::isnan everywhere?

I'm curious why isnan() doesn't work as is.

https://codereview.chromium.org/2022793002/

joc...@chromium.org

unread,
May 30, 2016, 4:02:10 PM5/30/16
to phajd...@chromium.org, the...@chromium.org, pdfium-...@googlegroups.com
On 2016/05/30 at 19:56:31, thestig wrote:
> On 2016/05/30 19:38:11, jochen wrote:
> > Why not use std::isnan everywhere?
>
> I'm curious why isnan() doesn't work as is

isnan is c99 which msvs doesn't support while cmath / std::isnan is supported or
something

https://codereview.chromium.org/2022793002/

the...@chromium.org

unread,
May 30, 2016, 4:23:39 PM5/30/16
to phajd...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
On 2016/05/30 20:02:10, jochen wrote:
> On 2016/05/30 at 19:56:31, thestig wrote:
> > On 2016/05/30 19:38:11, jochen wrote:
> > > Why not use std::isnan everywhere?
> >
> > I'm curious why isnan() doesn't work as is
>
> isnan is c99 which msvs doesn't support while cmath / std::isnan is supported
or
> something

But this is on Linux and has nothing to do with MSVS. Basically the change is
fine, but I'd like to understand why the code as is works fine on Ubuntu, but
not on some other Linux system with GCC 5.3.

https://codereview.chromium.org/2022793002/

phajd...@chromium.org

unread,
May 31, 2016, 4:29:25 AM5/31/16
to the...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
On 2016/05/30 at 19:32:30, thestig wrote:
> What's the build environment where this is failing? Does this sample program
work?
>
> ----
> #include <math.h>
> int main() { return isnan(5) ? 1 : 0; }
> ---

$ g++ --version
g++ (Gentoo 5.3.0 p1.1, pie-0.6.5) 5.3.0

This compiles:
---
#include <math.h>
int main() { return isnan(5.0) ? 1 : 0; }
---

Now when I do this:
---
#include <cmath>
#include <math.h>
int main() { return isnan(5.0) ? 1 : 0; }
---

$ g++ math.c -o math
$ echo $?
0
$ g++ -std=gnu++11 math.c
math.c: In function 'int main()':
math.c:3:30: error: 'isnan' was not declared in this scope
int main() { return isnan(5.0) ? 1 : 0; }
^
math.c:3:30: note: suggested alternative:
In file included from math.c:1:0:

/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/include/g++-v5/cmath:641:5: note:
'std::isnan'
isnan(_Tp __x)
^

Interestingly, above compiles just fine with gcc in Ubuntu Trusty (g++ (Ubuntu
4.8.4-2ubuntu1~14.04.3) 4.8.4).

https://codereview.chromium.org/2022793002/

the...@chromium.org

unread,
May 31, 2016, 2:59:15 PM5/31/16
to phajd...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
lgtm

I can reproduce this with g++ 5.3.1 on Ubuntu 16.04 as well. Looks like there
wass a conflict between isnan() and std::isnan(), so now when <cmath> is
included, isnan() does not get defined in math.h.

https://codereview.chromium.org/2022793002/

commit-bot@chromium.org via codereview.chromium.org

unread,
May 31, 2016, 2:59:18 PM5/31/16
to phajd...@chromium.org, the...@chromium.org, joc...@chromium.org, commi...@chromium.org, pdfium-...@googlegroups.com

commit-bot@chromium.org via codereview.chromium.org

unread,
May 31, 2016, 3:20:41 PM5/31/16
to phajd...@chromium.org, the...@chromium.org, joc...@chromium.org, commi...@chromium.org, pdfium-...@googlegroups.com

the...@chromium.org

unread,
May 31, 2016, 4:10:12 PM5/31/16
to phajd...@chromium.org, joc...@chromium.org, pdfium-...@googlegroups.com
On 2016/05/31 18:59:15, Lei Zhang wrote:
> I can reproduce this with g++ 5.3.1 on Ubuntu 16.04 as well. Looks like there
> wass a conflict between isnan() and std::isnan(), so now when <cmath> is
> included, isnan() does not get defined in math.h.

FWIW, I then built PDFium without this CL on the same Ubuntu 16.04 machine, but
didn't hit this problem. *shrug*

https://codereview.chromium.org/2022793002/
Reply all
Reply to author
Forward
0 new messages