What GCC version had <stdint.h> defined?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scott David Daniels

    #1

    What GCC version had <stdint.h> defined?

    I am trying to figure out how to get 2.4a2 to build a python
    extension. GCC 2.2.95 does not have a stdint.h, but 3.2.3 does.
    These two are the only gcc versions I have on my box.

    Does anyone know which version of GCC introduced stdint.h (and
    thereby uintptr_t and intptr_t)? I'd like to get the conditionals
    right.

    -Scott David Daniels
    Scott.Daniels@A cm.Org
  • Martin v. Löwis

    #2
    Re: What GCC version had &lt;stdint.h&gt ; defined?

    Scott David Daniels wrote:[color=blue]
    > Does anyone know which version of GCC introduced stdint.h (and
    > thereby uintptr_t and intptr_t)? I'd like to get the conditionals
    > right.[/color]

    stdint.h is not part of GCC; it is part of libc6. You shouldn't do
    #ifdefs based on version numbers, but instead, you should do checks
    based on the features of the software, like autoconf does.

    Regards,
    Martin

    Comment

    • Scott David Daniels

      #3
      Re: What GCC version had &lt;stdint.h&gt ; defined?

      Martin v. Löwis wrote:
      [color=blue]
      > Scott David Daniels wrote:
      >[color=green]
      >> Does anyone know which version of GCC introduced stdint.h (and
      >> thereby uintptr_t and intptr_t)? I'd like to get the conditionals
      >> right.[/color]
      >
      >
      > stdint.h is not part of GCC; it is part of libc6. You shouldn't do
      > #ifdefs based on version numbers, but instead, you should do checks
      > based on the features of the software, like autoconf does.
      >
      > Regards,
      > Martin[/color]

      Well, currently pyconfig.h for 2.4 says:
      ...
      #if _MSC_VER != 1200
      #define HAVE_UINTPTR_T 1
      #define HAVE_INTPTR_T 1
      #endif
      ...

      which is actually a pretty low bar to get over.

      I'd like to change it to something like:
      ...
      #if _MSC_VER > 1200
      #define HAVE_UINTPTR_T 1
      #define HAVE_INTPTR_T 1
      #endif
      ...
      #if GCC_VERSION >= 30100
      #define HAVE_UINTPTR_T 1
      #define HAVE_INTPTR_T 1
      #endif
      ...

      which is arguably better even if not good enough.
      Is there a better test I can do at compile time?

      -Scott David Daniels
      Scott.Daniels@A cm.Org

      Comment

      • Jeff Epler

        #4
        Re: What GCC version had &lt;stdint.h&gt ; defined?

        I glanced at configure.in and it checks for HAVE_UINTPTR_T, but not
        HAVE_INTPTR_T. If you want this define where it's available, add the
        proper test to configure.in and regenerate configure.

        I think the block would be something like this, a straightforward
        search-and-replace of the block for HAVE_UINTPTR_T:
        AC_MSG_CHECKING (for intptr_t support)
        have_intptr_t=n o
        AC_TRY_COMPILE([], [intptr_t x; x = (intptr_t)0;], [
        AC_DEFINE(HAVE_ INTPTR_T, 1, [Define this if you have the type
        intptr_t.])
        have_intptr_t=y es
        ])
        AC_MSG_RESULT($ have_intptr_t)
        if test "$have_intptr_t " = yes ; then
        AC_CHECK_SIZEOF (intptr_t, 4)
        fi
        on the other hand, maybe this test is broken, because my system (Fedora
        Core 2) configured with #undef HAVE_UINTPTR_T.

        Maybe this article shows the way:


        AC_MSG_CHECKING (for uintptr_t in C library)
        AC_CACHE_VAL(gd b_cv_have_uintp tr_t,
        [AC_TRY_COMPILE([#include <stdint.h>],
        [uintptr_t foo = 0;
        return foo;],
        gdb_cv_have_uin tptr_t=yes,
        gdb_cv_have_uin tptr_t=no)])
        AC_MSG_RESULT($ gdb_cv_have_uin tptr_t)
        if test $gdb_cv_have_ui ntptr_t = yes; then
        AC_DEFINE(HAVE_ UINTPTR_T)
        fi
        ... with appropriate renaming for Python.

        I'm not sure why uintptr_t or intptr_t are all that useful, since the
        spellings "unsigned *" and "int *" are going to work everywhere anyway.

        Jeff

        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.2.5 (GNU/Linux)

        iD8DBQFBLpviJd0 1MZaTXX0RAhrDAJ 9O9ss+lXpcDRn5Q/r4ftGHPzDRCACgi fvK
        z5TGV6FUIFnmmtp p7tA2pg0=
        =4FLF
        -----END PGP SIGNATURE-----

        Comment

        • Tim Peters

          #5
          Re: What GCC version had &lt;stdint.h&gt ; defined?

          [Jeff Epler]
          ....[color=blue]
          > I'm not sure why uintptr_t or intptr_t are all that useful, since the
          > spellings "unsigned *" and "int *" are going to work everywhere
          > anyway.[/color]

          intptr_t isn't a pointer type, it's a signed integer type wide enough
          so that, for every valid void* P,

          (void*)(intptr_ t)P == P

          C99 refuses to guarantee that such a type exists, but Python requires
          one (and int, long or "long long" is big enough on all Python
          platforms to date).

          Similarly for uintptr_t.

          Comment

          • Scott David Daniels

            #6
            Re: What GCC version had &lt;stdint.h&gt ; defined?

            Jeff Epler wrote:[color=blue]
            > I glanced at configure.in and it checks for HAVE_UINTPTR_T, but not
            > HAVE_INTPTR_T. If you want this define where it's available, add the
            > proper test to configure.in and regenerate configure.[/color]

            The problem is, of course (Billy G is always a problem), that I am running
            on Win2K, so I don't run configure.in. I have two copies of MinGW --
            one 2.95 (no stdint.h), and one 3.2.3 which does do stdint.h.
            These were not set up when whoever built windows 2.3.4 did so -- he or
            she did not know what was going to be on my disk after I downloaded and
            installed python.

            So, for me and my ilk ("isn't 'ilk' a lovely word" -- Albee), pyconfig.h
            is a constant, not a calculated value.


            -Scott David Daniels
            Scott.Daniels@A cm.Org

            Comment

            • Martin v. Löwis

              #7
              Re: What GCC version had &lt;stdint.h&gt ; defined?

              Scott David Daniels wrote:[color=blue]
              > I'd like to change it to something like:
              > ...
              > #if _MSC_VER > 1200
              > #define HAVE_UINTPTR_T 1
              > #define HAVE_INTPTR_T 1
              > #endif
              > ...
              > #if GCC_VERSION >= 30100
              > #define HAVE_UINTPTR_T 1
              > #define HAVE_INTPTR_T 1
              > #endif
              > ...
              >
              > which is arguably better even if not good enough.[/color]

              That won't help at all. PC/pyconfig.h is used only
              on Windows, not on Linux. On Linux, configure is run
              to detect presence of things.
              [color=blue]
              > Is there a better test I can do at compile time?[/color]

              Depends on what you want to test for. If it is
              presence of stdint.h, you should test for
              HAVE_STDINT_H.

              Regards,
              Martin

              Comment

              • Martin v. Löwis

                #8
                Re: What GCC version had &lt;stdint.h&gt ; defined?

                Scott David Daniels wrote:[color=blue]
                > The problem is, of course (Billy G is always a problem), that I am running
                > on Win2K, so I don't run configure.in. I have two copies of MinGW --
                > one 2.95 (no stdint.h), and one 3.2.3 which does do stdint.h.
                > These were not set up when whoever built windows 2.3.4 did so -- he or
                > she did not know what was going to be on my disk after I downloaded and
                > installed python.[/color]

                Can you please explain what the problem is that you are trying to solve?
                Apparently, it is not compiling Python.

                If you are trying to compile a Python extension, can't you just check
                for presence of /usr/include/stdint.h in setup.py?

                But then, if you are compiling an extension - why do you even *need*
                to know whether stdint.h is present?

                Regards,
                Martin

                Comment

                • Andrew MacIntyre

                  #9
                  Re: What GCC version had &lt;stdint.h&gt ; defined?

                  On Thu, 26 Aug 2004, Scott David Daniels wrote:
                  [color=blue]
                  > The problem is, of course (Billy G is always a problem), that I am running
                  > on Win2K, so I don't run configure.in. I have two copies of MinGW --
                  > one 2.95 (no stdint.h), and one 3.2.3 which does do stdint.h.
                  > These were not set up when whoever built windows 2.3.4 did so -- he or
                  > she did not know what was going to be on my disk after I downloaded and
                  > installed python.[/color]

                  In this context, stdint.h is not a part of gcc per se, but rather a
                  part of the MinGW development environment - in the same way that a lot of
                  other header files in MinGW's include directory are not part of the
                  standard gcc distribution.

                  If the module code in question can be built on Unixish platforms, ISTM
                  you should protect your special MinGW'isms with an #ifdef WIN32, to avoid
                  problems with Python installations built with configure.

                  The question that I think you are trying to ask is "which version of MinGW
                  introduced stdint.h", and then see if there's a define you can use...
                  (I don't know of one, but then I've only used MinGW 1.1 which contains gcc
                  2.95).

                  --
                  Andrew I MacIntyre "These thoughts are mine alone..."
                  E-mail: andymac@bullsey e.apana.org.au (pref) | Snail: PO Box 370
                  andymac@pcug.or g.au (alt) | Belconnen ACT 2616
                  Web: http://www.andymac.org/ | Australia

                  Comment

                  • Scott David Daniels

                    #10
                    Re: What GCC version had &lt;stdint.h&gt ; defined?

                    Martin v. Löwis wrote:
                    [color=blue]
                    > Scott David Daniels wrote:
                    >[color=green]
                    >> I'd like to change it <pyconfig.h> to something like:
                    >> ...
                    >> #if _MSC_VER > 1200
                    >> #define HAVE_UINTPTR_T 1
                    >> #define HAVE_INTPTR_T 1
                    >> #endif
                    >> ...
                    >> #if GCC_VERSION >= 30100
                    >> #define HAVE_UINTPTR_T 1
                    >> #define HAVE_INTPTR_T 1
                    >> #endif
                    >> ...
                    >> which is arguably better even if not good enough.[/color][/color]
                    [color=blue]
                    > That won't help at all. PC/pyconfig.h is used only
                    > on Windows, not on Linux. On Linux, configure is run
                    > to detect presence of things.[/color]

                    Ah -- but my problem (which I was remiss in not describing well
                    enough) is just that I cannot compile _at_ _all_ on the Windows
                    box with minGW. I don't give a whit about <stdint.h> except to
                    try to make sure the proper definition happens. I'd like the
                    following extension to compile for 2.4 (it won't now) with MinGW:

                    #include <Python.h>

                    static PyMethodDef xyzMethods[] = {
                    {NULL, NULL, 0, NULL} /* Sentinel */
                    };

                    #if defined(PyMODIN IT_FUNC)
                    PyMODINIT_FUNC
                    #else
                    void
                    #endif
                    initxyz(void)
                    {
                    PyObject *module = Py_InitModule(" xyz", xyzMethods);
                    PyModule_AddStr ingConstant(mod ule, "test", "value");
                    }

                    The error is roughly:
                    In file included from C:/python24/include/Python.h:55,
                    from xyzmodule.c:1:
                    C:/python24/include/pyport.h:69: parse error before "Py_uintptr _t"
                    C:/python24/include/pyport.h:69: warning: type defaults to `int'
                    in declaration of `Py_uintptr_t'
                    C:/python24/include/pyport.h:69: warning: data definition has
                    no type or storage class
                    C:/python24/include/pyport.h:70: parse error before "Py_intptr_ t"
                    C:/python24/include/pyport.h:70: warning: type defaults to `int'
                    in declaration of `Py_intptr_t'
                    C:/python24/include/pyport.h:70: warning: data definition has
                    no type or storage class
                    error: command 'gcc' failed with exit status 1


                    That is, I don't even get to my _own_ broken code.
                    [color=blue][color=green]
                    >> #if _MSC_VER > 1200
                    >> #define HAVE_UINTPTR_T 1[/color][/color]
                    [color=blue][color=green]
                    >> Is there a better test I can do at compile time?[/color]
                    >
                    > Depends on what you want to test for. If it is
                    > presence of stdint.h, you should test for
                    > HAVE_STDINT_H.
                    >
                    > Regards,
                    > Martin[/color]

                    How is this as a change:

                    From this:
                    #ifdef MS_WIN32
                    ...
                    /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version
                    number of 1200. If some compiler does not provide them,
                    modify the #if appropriately. */
                    #if _MSC_VER != 1200
                    #define HAVE_UINTPTR_T 1
                    #define HAVE_INTPTR_T 1
                    #endif

                    #endif


                    To this:

                    #ifdef MS_WIN32
                    ...
                    /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version
                    number of 1200. If some compiler does not provide them,
                    modify the #if appropriately. */
                    #if _MSC_VER > 1200
                    #define HAVE_UINTPTR_T 1
                    #define HAVE_INTPTR_T 1
                    #elif HAVE_STDINT_H
                    #define HAVE_UINTPTR_T 1
                    #define HAVE_INTPTR_T 1
                    #endif

                    #endif


                    Or if HAVE_STDINT_H is defined under VC 7.1 (I cannot check that)
                    perhaps the change should become:

                    #ifdef MS_WIN32
                    ...

                    #if HAVE_STDINT_H
                    #define HAVE_UINTPTR_T 1
                    #define HAVE_INTPTR_T 1
                    #endif

                    #endif

                    In any case, thanks for the help so far.

                    -Scott David Daniels
                    Scott.Daniels@A cm.Org

                    Comment

                    • Scott David Daniels

                      #11
                      Re: What GCC version had &lt;stdint.h&gt ; defined?

                      I've submitted patch # 1020042 for this problem.

                      Comment

                      Working...