isnan in C++ compilation

164 views
Skip to first unread message

Francisco Lahuerta Calahorra

unread,
Oct 24, 2013, 7:31:42 AM10/24/13
to cython...@googlegroups.com
When cython is compile in C, in order to use isnan extern function I use the following

cdef extern from "math.h" nogil:
    bint isnan(DTYPE_t x)

however when the same code is compile in C++ with language='c++' in the setup script
I get the following error 

error: 'isnan' was not declared in this scope

how can I declare a new definition for isnan with C++ compilation

thanks

Robert Bradshaw

unread,
Oct 25, 2013, 1:00:37 AM10/25/13
to cython...@googlegroups.com
cdef extern from "<cmath>" namespace "std":
bint isnan(DTYPE_t x) nogil

Francisco Lahuerta Calahorra

unread,
Oct 25, 2013, 2:43:38 AM10/25/13
to cython...@googlegroups.com
That works, thanks

Stefan Behnel

unread,
Oct 25, 2013, 6:14:19 AM10/25/13
to cython...@googlegroups.com
Robert Bradshaw, 25.10.2013 07:00:
> On Thu, Oct 24, 2013 at 4:31 AM, Francisco Lahuerta Calahorra wrote:
>> When cython is compile in C, in order to use isnan extern function I use the
>> following
>>
>>> cdef extern from "math.h" nogil:
>>> bint isnan(DTYPE_t x)
>>
>>
>> however when the same code is compile in C++ with language='c++' in the
>> setup script
>> I get the following error
>>
>>> error: 'isnan' was not declared in this scope
>>
>>
>> how can I declare a new definition for isnan with C++ compilation
>
> cdef extern from "<cmath>" namespace "std":
> bint isnan(DTYPE_t x) nogil

Would it be worth adding this as

libcpp.cmath

.pxd module ?

Stefan

Lisandro Dalcin

unread,
Oct 26, 2013, 3:54:41 PM10/26/13
to cython-users
What about all the others pxds in libc/* ? Too bad we cannot "include"
on a cdef block, this would let us easily expose all of libc in libcpp
without duplicating the declarations:

# libc/math.pxd
cdef extern from "math.h" nogil:
include "./math.pxd.in"

# libcpp/cmath.pxd
cdef extern from "cmath" namespace "std" nogil:
include "../libc/math.pxd.in"



--
Lisandro Dalcin
---------------
CIMEC (UNL/CONICET)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1016)
Tel/Fax: +54-342-4511169
Reply all
Reply to author
Forward
0 new messages