#1211 mingwrt-3.15: gcc fails if __MSVCRT_VERSION__>=0x0800

closed-fixed
2008-09-25
2008-09-24
No

Os WinXP Home Ru + sp3
g++ (GCC) 3.4.5 (mingw-vista special r3)
GNU ld (GNU Binutils) 2.18.50.20080109
binutils-2.18.50-20080109-2.tar.gz
mingwrt-3.15-mingw32-dev.tar.gz
mingwrt-3.15-mingw32-dll.tar.gz
w32api-3.12-mingw32-dev.tar.gz

Test source (mini2.c):
#include <windows.h>

int STDCALL
WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) {
MessageBox (NULL, "Test message", "Test", MB_OK);
return 0;
}

Command line and output:
C:\test>gcc -c -D__MSVCRT_VERSION__=0x0800 mini2.c
In file included from C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/objbase.h:12,
from C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/ole2.h:9,
from C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:114,
from mini2.c:1:
C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdlib.h:470: error: syntax error before "uintptr_t"

Discussion

  • If define __MSVCRT_VERSION__=0x0900 also error
    Command line and output:
    C:\test>gcc -c -D__MSVCRT_VERSION__=0x0900 mini2.c
    In file included from C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/objbase.h:12,
    from C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/ole2.h:9,
    from C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:114,
    from mini2.c:1:
    C:/Lang/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdlib.h:470: error: syntax error before "uintptr_t"

     
  • Keith Marshall
    Keith Marshall
    2008-09-24

    Thanks.

    I've identified the error, as described below. As a workaround, if you don't want to fix it locally in your own headers, you may #include stdint.h, *before* stdlib.h.

    Chris, I can pick this one up, unless you'd prefer to handle it yourself.

    The error is in stdlib.h; at line 452 I see:
    #if __MSVCRT_VERSION__ >= 0x800
    #ifndef _INTPTR_T_DEFINED
    #define _INTPTR_T_DEFINED
    #ifdef _WIN64
    typedef __int64 intptr_t;
    #else
    typedef int intptr_t;
    #endif
    #endif

    but this is never used. Later, at line 466 I see (reformatted):
    typedef void
    (* _invalid_parameter_handler) (
    const wchar_t *,
    const wchar_t *,
    const wchar_t *,
    unsigned int,
    uintptr_t);

    requiring `uintptr_t' and not `intptr_t'. This suggests that the defines at line 452 should actually be (reproduced from stdint.h, and reformatted):
    # if __MSVCRT_VERSION__ >= 0x800
    # ifndef _UINTPTR_T_DEFINED
    # define _UINTPTR_T_DEFINED
    # ifdef _WIN64
    typedef unsigned __int64 uintptr_t;
    # else
    typedef unsigned int uintptr_t;
    # endif
    # endif

     
  • Keith Marshall
    Keith Marshall
    2008-09-24

    • assigned_to: nobody --> keithmarshall
    • summary: Error compile for defined MSVCRT_VERSION=0x0800 --> mingwrt-3.15: gcc fails if MSVCRT_VERSION>=0x0800
     
  • > Chris, I can pick this one up, unless you'd prefer to handle it yourself.

    Please feel free Keith. I'd like to role out a new mingwrt soon to deal with an issue with -std=gnu99 in stdio.h that shipped with 3.15 and was corrected with your subsequent commit.

    Thanx!

    Chris

     
  • Keith Marshall
    Keith Marshall
    2008-09-25

    • milestone: --> IINR_-_Include_In_Next_Release
    • status: open --> closed-fixed
     
  • Keith Marshall
    Keith Marshall
    2008-09-25

    Patch applied:

    * include/stdlib.h (intptr_t) [!_INTPTR_T_DEFINED]: Unused typedef;
    not wanted here; remove it; replace it by...
    (uintptr_t) [!_UINTPTR_T_DEFINED]: ...this typedef; needed by...
    (_invalid_parameter_handler): ...this function typedef.

     
  • Keith Marshall
    Keith Marshall
    2008-09-26

    Chris,

    > I'd like to role out a new mingwrt soon...

    That's a reasonable suggestion. IMO, it wouldn't merit a 3.16 release, but I'd suggest 3.15.1 rather than simply a snapshot. Perhaps we should also address the version indication in configure, while we're about it.

    I did post a note to this effect, on MinGW-Dvlpr, but it seems to have vanished into a black hole somewhere; if it hasn't turned up later this evening, I'll post it again.

     
  • > That's a reasonable suggestion. IMO, it wouldn't merit a 3.16 release,
    > but I'd suggest 3.15.1 rather than simply a snapshot. Perhaps we should
    > also address the version indication in configure, while we're about it.

    Agreed. I can simply set __MINGW32_VERSION to 3.15.1 and __MINGW32_MINOR_VERSION to 15.1 in _mingw.h, or were you thinking of something more?

     
  • Keith Marshall
    Keith Marshall
    2008-09-27

    > Agreed. I can simply set __MINGW32_VERSION to 3.15.1

    Yes.

    > and __MINGW32_MINOR_VERSION to 15.1

    No, this needs to be kept as an integer value, so it can be tested in preprocessor conditionals. You may add an additional __MINGW32_PATCHLEVEL define, if you wish to record the third component of the combined version number, otherwise than only within __MINGW32_VERSION.

    > or were you thinking of something more?

    I was also thinging of the unsatisfactory version reporting, when you run `configure --help'.