Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang build error wrt isnan and isinf #863

Closed
int19h opened this issue Dec 29, 2016 · 5 comments
Closed

Clang build error wrt isnan and isinf #863

int19h opened this issue Dec 29, 2016 · 5 comments
Labels

Comments

@int19h
Copy link
Contributor

int19h commented Dec 29, 2016

canvas 1.5.0, but the offending code is also in master.

Happens due to this line:

https://github.com/Automattic/node-canvas/blob/master/src/CanvasRenderingContext2d.cc#L29

So all isnan references in the file are expanded to std::isnan, if global isnan is not a macro. But it is not a macro on Clang, it's a plain function. And then, because the file includes math.h rather than cmath, it fails to find isnan in std (math.h only guarantees that the things that it defines are in the global namespace; that it happens to also bring them into std on some implementations is a non-standard quirk of those implementations). Same thing is happening with isinf.

../src/CanvasRenderingContext2d.cc:2212:21: error: no member named
'isnan' in namespace 'std'; did you mean simply 'isnan'?
    if (a[i] < 0 || isnan(a[i]) || isinf(a[i])) return;
                    ^~~~~~~~~~~
../src/CanvasRenderingContext2d.cc:33:18: note: expanded from macro 'isnan'
#define isnan(x) std::isnan(x)
                 ^~~~~
/usr/include/c++/v1/math.h:428:1: note: 'isnan' declared here
isnan(_A1 __lcpp_x) _NOEXCEPT
^

This is Clang 3.8.0 on FreeBSD, but I believe it'll repro on any platform, because the included header is from the Clang standard library. You can see what their math.h and cmath look like here:

https://github.com/llvm-mirror/libcxx/blob/master/include/math.h
https://github.com/llvm-mirror/libcxx/blob/master/include/cmath

The fix should be to simply #include <cmath> instead of <math.h>, or else drop the std:: and just use isinf / isnan from global namespace directly.

@int19h
Copy link
Contributor Author

int19h commented Jan 2, 2017

Verified that this one change does make it build on FreeBSD. PR coming shortly.

@LinusU
Copy link
Collaborator

LinusU commented Feb 14, 2017

Fixed in 1.6.3

@LinusU LinusU closed this as completed Feb 14, 2017
@pratiknagariya
Copy link

I am still getting this error with node v8.

../src/CanvasRenderingContext2d.cc:2197:21: error: no member named 'isnan' in namespace 'std' if (a[i] < 0 || isnan(a[i]) || isinf(a[i])) return; ^~~~~~~~~~~ ../src/CanvasRenderingContext2d.cc:33:23: note: expanded from macro 'isnan' #define isnan(x) std::isnan(x) ~~~~~^ ../src/CanvasRenderingContext2d.cc:2197:36: error: no member named 'isinf' in namespace 'std' if (a[i] < 0 || isnan(a[i]) || isinf(a[i])) return; ^~~~~~~~~~~ ../src/CanvasRenderingContext2d.cc:34:23: note: expanded from macro 'isinf' #define isinf(x) std::isinf(x) ~~~~~^ ../src/CanvasRenderingContext2d.cc:2231:7: error: no member named 'isnan' in namespace 'std' if (isnan(offset) || isinf(offset)) return; ^~~~~~~~~~~~~ ../src/CanvasRenderingContext2d.cc:33:23: note: expanded from macro 'isnan' #define isnan(x) std::isnan(x) ~~~~~^ ../src/CanvasRenderingContext2d.cc:2231:24: error: no member named 'isinf' in namespace 'std' if (isnan(offset) || isinf(offset)) return; ^~~~~~~~~~~~~ ../src/CanvasRenderingContext2d.cc:34:23: note: expanded from macro 'isinf' #define isinf(x) std::isinf(x) ~~~~~^ 1 warning and 4 errors generated. make: *** [Release/obj.target/canvas/src/CanvasRenderingContext2d.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/ashishy/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.3.0
gyp ERR! command "/Users/ashishy/.nvm/versions/node/v8.9.4/bin/node" "/Users/ashishy/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Volumes/Work/CA/projects/version8/digit-foundational-reading/node_modules/resemble/node_modules/canvas
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN marked-terminal@2.0.0 requires a peer of marked@^0.3.6 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.3.16 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.3.16 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ashishy/.npm/_logs/2018-03-19T12_36_30_104Z-debug.log`

@zbjornson
Copy link
Collaborator

zbjornson commented Mar 19, 2018

canvas@1.3.16

This was fixed in 1.6.3. You need to use a newer version (or a newer version of resemble that uses a newer version of canvas).

@pratiknagariya
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants