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

Fix deprecation warning from mNaN. #12

Closed
cdeil opened this issue Dec 6, 2013 · 2 comments · Fixed by #211
Closed

Fix deprecation warning from mNaN. #12

cdeil opened this issue Dec 6, 2013 · 2 comments · Fixed by #211
Milestone

Comments

@cdeil
Copy link
Member

cdeil commented Dec 6, 2013

I get this warning in the build:

/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -Os -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c reproject/overlapArea.c -o build/temp.macosx-10.9-x86_64-2.7/reproject/overlapArea.o
reproject/overlapArea.c:1262:7: warning: 'finite' is deprecated: first deprecated in OS X 10.9 [-Wdeprecated-declarations]
   if(mNaN(area) || area < 0.)
      ^
reproject/mNaN.h:7:30: note: expanded from macro 'mNaN'
#define mNaN(x) isnan(x) || !finite(x)
                             ^
/usr/include/math.h:718:12: note: 'finite' declared here
extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA);
           ^
1 warning generated.

I'll have to look around what the proper and equivalent way of handling NaNs in this way is unless someone else knows.
Tests with input NaNs should be in place first.

@astrofrog
Copy link
Member

I think finite should be replaced by isfinite, but not sure whether only very recent compilers support it. If so, we shouldn't make this change yet. Maybe @bluescarni can clarify whether this change would be safe?

@astrofrog astrofrog added this to the Future milestone Oct 14, 2014
@bluescarni
Copy link
Contributor

@astrofrog isfinite() is a macro available since C99:

http://en.cppreference.com/w/c/numeric/math/isfinite

Quoting from the GCC manpage:

By default, GCC provides some extensions to the C language that on rare occasions conflict with the C standard. See Extensions to the C Language Family. Use of the -std options listed above will disable these extensions where they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with -std=gnu90 (for C90 with GNU extensions), -std=gnu99 (for C99 with GNU extensions) or -std=gnu11 (for C11 with GNU extensions). The default, if no C language dialect options are given, is -std=gnu90; this is intended to change to -std=gnu11 in some future release. Some features that are part of the C99 standard are accepted as extensions in C90 mode, and some features that are part of the C11 standard are accepted as extensions in C90 and C99 modes.

https://gcc.gnu.org/onlinedocs/gcc/Standards.html

So it seems to depend on what kind of compiler flags are passed by distutils down to the compiler, at least in the case of GCC. On OSX I would expect clang to follow more or less what GCC does.

On Windows, MSVC notoriously has poor C99 support, especially in earlier versions (the latest ones seem to have better support).

Pragmatically, for GCC my first choice would be to see if it "just works" in gnu90 mode -- maybe the macro is included in the extensions mentioned above. This seems to be the case on my machine:

#include <math.h>

int main()
{
        isfinite(4.5);
}

This compiles fine on my machine without extra switches (GCC 4.9). This is the type of things that, generally speaking, should be tested when configuring the build system.

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

Successfully merging a pull request may close this issue.

3 participants