[Pyrex] "Language Overview" confusion
David Goldsmith
David.L.Goldsmith at noaa.gov
Tue Jun 5 22:07:34 UTC 2007
So the sentence:
"It's important to understand that Pyrex does /not/ itself read the C
header file, so you still need to provide Pyrex versions of any
declarations from it that you use"
is *not* describing something you "still" have to do after you've done
the declarations example-d above it, but rather *explaining why* you
have to provide those declarations? In other words, if the example
declaration is an example of a "Pyrex version of [a] declaration," then
the "...Pyrex does /not/ itself read the C header file, so you still
need to provide..." portion of the sentence is confusing.
DG
Bob Van Zant wrote:
> On 6/5/07 2:41 PM, "David Goldsmith" <David.L.Goldsmith at noaa.gov> wrote:
>
>
>> As a newbie, I have no idea what the second part of this sentence means:
>> "provide Pyrex versions of any declarations" - where (i.e., in which
>> file)? What do these look like?
>>
>> (By implication, the previous example:
>>
>> cdef extern from "spam.h":
>>
>> int spam_counter
>>
>> void order_spam(int tons)
>>
>> (which goes in the .pyx file, yes?) is *not* such a declaration, but no
>> positive example of such a declaration appears to be given, at least not
>> at that place in the LO, and it is not clear in which file said
>> declaration should go).
>>
>
> Those actually are the declarations. The "cdef extern from..." will
> eventually turn into a #include line. The rest of the declarations tell
> Pyrex about the variables, functions and types you'll be using.
>
> These can go directly in the .pyx file. For instance, to get strlen you
> could put this into your .pyx file:
>
> cdef extern from "string.h":
> size_t strlen(char *s)
>
> You can then just call strlen() from within your pyrex. If you have more
> than a few of these declarations you can put them into a separate file with
> extension .pxi and then include that from your .pyx file.
>
> -Bob
>
>
--
ERD/ORR/NOS/NOAA <http://response.restoration.noaa.gov/emergencyresponse/>
More information about the Pyrex
mailing list