On 2017/9/13 0:15, Eli Zaretskii wrote:
You'd need to disassemble (or at least check with nm) the
object/function to find out if it's calling __mingw_printf or regular
printf, seems like emacs is using %lld and %I64 in different places.

%lld is used for intmax_t values, %I64d is used for 64-bit values.

Are you saying that MinGW64 doesn't support both %lld and %I64d?  If
so, under which conditions is each one supported?


`printf()` provided by MSVCRT recognizes only `%I64d`, while `__mingw_printf()` provided by MinGW-w64, which takes over `printf()` due to `__USE_MINGW_ANSI_STDIO`, recognizes only `%lld`.

FWIW, with a C99-conforming `printf()` you can use `%jd` for `intmax_t`...

Check if keyboard.c and print.c is using __USE_MINGW_ANSI_STDIO
consistently.

The Emacs config.h defines __USE_MINGW_ANSI_STDIO, and all sources
include config.h.  So yes, this is used consistently.

What is the effect of __USE_MINGW_ANSI_STDIO on format specs
recognized by the MinGW64 GCC 7 compiler at compile time?


This isn't related to the version of GCC, but to the version of MinGW-w64 you have.

If `__USE_MINGW_ANSI_STDIO` is defined to something non-zero and <intypes> is included *after* <stdio.h> or <wchar.h>, you get `%lld` for `PRIdMAX`, otherwise you get `%I64d`. This basically covers three cases:

Case 1:
```
#include <stdio.h>
#include <inttypes.h>
int main(void){
  /* Calls `printf()` from MSVCRT.
     Outputs `I64d 42`  */
  printf("%s: %" PRIdMAX, PRIdMAX, INTMAX_C(42));
}
```

Case 2:
```
#define __USE_MINGW_ANSI_STDIO 1
#include <stdio.h>
#include <inttypes.h>
int main(void){
  /* Calls `__mingw_printf()` from MinGW-w64.
     Outputs `lld 42`  */
  printf("%s: %" PRIdMAX, PRIdMAX, INTMAX_C(42));
}
```

Case 3:
```
#define __USE_MINGW_ANSI_STDIO 1
/* The user declares such a function {him,her}self...
   LD will resolve references to this function to the MSVCRT one,
   which accepts `%I64d`, rather than `%lld`.  */
extern int printf(const char *, ...);
#include <inttypes.h>
int main(void){
  /* Calls `printf()` from MSVCRT.
     Outputs "I64d 42"  */
  printf("%s: %" PRIdMAX, PRIdMAX, INTMAX_C(42));
}
```

--
Best regards,
LH_Mouse


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to