Re: (from stdlib-sig) ctypes or struct from an h file

Discussion in 'Python' started by Diez B. Roggisch, Oct 18, 2009.

  1. Yuvgoog Greenle schrieb:
    > Is there a way that Python and C can have a shared definition for a
    > binary data structure?
    >
    > It could be nice if:
    > 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
    > to auto-generate constructors
    > or
    > 2. a ctypes definition could be exported to a .h file.
    >
    > So my question is - is there a way to do this in the std-lib or even pypi?
    >
    >
    > --yuv
    >
    >
    > ps If this doesn't exist, then I'm probably going to open a project
    > and would like some tips/ideas.



    gccxml can be used to do this, there is a ctypes utilities module that
    works with the output of gccxml.

    Diez
    Diez B. Roggisch, Oct 18, 2009
    #1
    1. Advertising

  2. On Sun, Oct 18, 2009 at 4:13 PM, Diez B. Roggisch <> wrote:
    > Yuvgoog Greenle schrieb:
    >>
    >> Is there a way that Python and C can have a shared definition for a
    >> binary data structure?
    >>
    >> It could be nice if:
    >> 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
    >> to auto-generate constructors
    >> or
    >> 2. a ctypes definition could be exported to a .h file.
    >>
    >> So my question is - is there a way to do this in the std-lib or even pypi?
    >>
    >>
    >> --yuv
    >>
    >>
    >> ps If this doesn't exist, then I'm probably going to open a project
    >> and would like some tips/ideas.

    >
    >
    > gccxml can be used to do this, there is a ctypes utilities module that works
    > with the output of gccxml.
    >
    > Diez
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >


    Found this: http://starship.python.net/crew/theller/ctypes/old/codegen.html
    which I take to be the module you're talking about. From the docs it doesn't
    appear to have worked with gccxml since before 0.6, which is more than 5
    years old. Am I at the wrong place?

    Geremy Condra
    geremy condra, Oct 18, 2009
    #2
    1. Advertising

  3. geremy condra schrieb:
    > On Sun, Oct 18, 2009 at 4:13 PM, Diez B. Roggisch <> wrote:
    >> Yuvgoog Greenle schrieb:
    >>> Is there a way that Python and C can have a shared definition for a
    >>> binary data structure?
    >>>
    >>> It could be nice if:
    >>> 1. struct or ctypes had a function that could parse a .h/.c/.cpp file
    >>> to auto-generate constructors
    >>> or
    >>> 2. a ctypes definition could be exported to a .h file.
    >>>
    >>> So my question is - is there a way to do this in the std-lib or even pypi?
    >>>
    >>>
    >>> --yuv
    >>>
    >>>
    >>> ps If this doesn't exist, then I'm probably going to open a project
    >>> and would like some tips/ideas.

    >>
    >> gccxml can be used to do this, there is a ctypes utilities module that works
    >> with the output of gccxml.
    >>
    >> Diez
    >> --
    >> http://mail.python.org/mailman/listinfo/python-list
    >>

    >
    > Found this: http://starship.python.net/crew/theller/ctypes/old/codegen.html
    > which I take to be the module you're talking about. From the docs it doesn't
    > appear to have worked with gccxml since before 0.6, which is more than 5
    > years old. Am I at the wrong place?


    Nope, that's it. I don't understand what you mean with "since before
    0.6" - all I can say is I got it working last year with a GCC 3.X or 4.x
    project.

    Diez
    Diez B. Roggisch, Oct 18, 2009
    #3
  4. Diez B. Roggisch

    Guest

    On 08:13 pm, wrote:
    >Yuvgoog Greenle schrieb:
    >>Is there a way that Python and C can have a shared definition for a
    >>binary data structure?
    >>
    >>It could be nice if:
    >>1. struct or ctypes had a function that could parse a .h/.c/.cpp file
    >>to auto-generate constructors
    >>or
    >>2. a ctypes definition could be exported to a .h file.
    >>
    >>So my question is - is there a way to do this in the std-lib or even
    >>pypi?
    >>
    >>
    >>--yuv
    >>
    >>
    >>ps If this doesn't exist, then I'm probably going to open a project
    >>and would like some tips/ideas.

    >
    >
    >gccxml can be used to do this, there is a ctypes utilities module that
    >works with the output of gccxml.
    >
    >Diez
    >--
    >http://mail.python.org/mailman/listinfo/python-list


    ctypes_configure can do this, too, doesn't require gccxml, and works
    with non-gcc compilers.

    Jean-Paul
    , Oct 18, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Fogelklou
    Replies:
    36
    Views:
    1,333
    Chris Fogelklou
    Apr 20, 2004
  2. Henk Punt
    Replies:
    0
    Views:
    385
    Henk Punt
    Jul 23, 2004
  3. Daniel Nogradi

    file -> open in stdlib patch

    Daniel Nogradi, Jan 24, 2007, in forum: Python
    Replies:
    0
    Views:
    296
    Daniel Nogradi
    Jan 24, 2007
  4. Replies:
    0
    Views:
    486
  5. matchstick86

    sig : process vs. process(sig)

    matchstick86, Oct 12, 2009, in forum: VHDL
    Replies:
    1
    Views:
    544
    power_hf2005
    Oct 13, 2009
Loading...

Share This Page