Very informative discussion. I see that Cython doesn't actually know the underlying types of typedefs because it doesn't parse any C headers. Cython doesn't even care about the exact length of the underlying type, just that it can order the types by rank to find which of two types is widest. When you write `ctypedef`, you're just telling Cython that two types are equivalent.

I second the opinion that the stdint.h typedefs in the standard library should have accurate definitions. This way `ctypedefs` that resolve to a stdint type will not be too wrong.

It might be safe just to change the ctypedefs for int64_t to `long long` - per the C99 standard, this type is *always* at least 64-bits long. (I don't know if all compilers adhere to this part of the spec and don't feel like getting a list of every compiler's opinion...but I know for sure it's 64 bits on MSVC, which doesn't claim to implement C99 nor even provide a stdint.h in the 2008 version.)

David Vierra
MCEdit, a Minecraft World Editor
http://www.mcedit.net
http://twitter.com/codewarrior0

On 7/2/2015 10:11 AM, Ian Henriksen wrote:
On Thu, Jul 2, 2015 at 1:08 PM Robert McGibbon <rmcgi...@gmail.com <mailto:rmcgi...@gmail.com>> wrote:

    Right, okay. I think I understand.

    -Robert

    On Thu, Jul 2, 2015 at 12:58 AM, Stefan Behnel
    <stefan...@behnel.de <mailto:stefan...@behnel.de>> wrote:

        Robert McGibbon schrieb am 02.07.2015 um 09:49:
        >> "libc.stdint.int64_t" is hand-wavingly declared as "long"
        >
        > There are some deeper issues in the rest of your message,
        but as a
        > preliminary matter, isn't this a clear error for linux-32
        and windows?

        No, it's not. That's just what Cython sees. The C compiler
        then sees the
        exact platform specific type. And as the vast amount of Cython
        code out
        there shows, it's usually not a problem in practice. Cython is
        designed to
        handle most of these "platform specific type" issues at C
        compile time
        rather than C code generation time. But as your example shows,
        it can't
        always hide the details entirely. And there can be bugs.

        Stefan

        _______________________________________________
        cython-devel mailing list
        cython-devel@python.org <mailto:cython-devel@python.org>
        https://mail.python.org/mailman/listinfo/cython-devel


    _______________________________________________
    cython-devel mailing list
    cython-devel@python.org <mailto:cython-devel@python.org>
    https://mail.python.org/mailman/listinfo/cython-devel


This is an interesting discussion. Thanks.
For the particular case of int64_t, wouldn't it still be wise to
make it a typedef of long long rather than just long so as to consistently get the correct size on platforms where long
is only 32 bits?
Thanks!
-Ian Henriksen


_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to