> Unfortunately, older MSVC (e.g. VC 2010) doesn't support "z" specifier.
> Do the warnings disappear if you change "%I" to "%I64"?
>
>
Hi Ken,
Changing them to "%I64" doesn't help:
<snip>
gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer
-freg-struct-return main.c -o gobjnative/main.o
In file included from main.c:11:
main.c: In function 'early_arg_scan':
vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format [-Wformat=]
343 | # define SCANF_HEX_LONG_U "%I64x"
| ^~~~~~~
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
343 | # define SCANF_HEX_LONG_U "%I64x"
| ^~~~~~~
vim.h:343:38: note: format string is defined here
343 | # define SCANF_HEX_LONG_U "%I64x"
| ^
vim.h:343:33: warning: format '%x' expects argument of type 'unsigned
int *', but argument 3 has type 'long_u *' {aka 'long lo
ng unsigned int *'} [-Wformat=]
343 | # define SCANF_HEX_LONG_U "%I64x"
| ^~~~~~~
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
343 | # define SCANF_HEX_LONG_U "%I64x"
| ^~~~~~~
vim.h:343:38: note: format string is defined here
343 | # define SCANF_HEX_LONG_U "%I64x"
| ~~~~^
| |
| unsigned int *
| %I64llx
vim.h:344:33: warning: unknown conversion type character 'I' in format
[-Wformat=]
344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
| ^~~~~~~~
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
| ^~~~~~~~
vim.h:344:38: note: format string is defined here
344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
| ^
vim.h:344:33: warning: too many arguments for format [-Wformat-extra-args]
344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
| ^~~~~~~~
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
| ^~~~~~~~
</snip>
However, putting the definitions around some ifdefs works for me, like
so (see attached):
<snip>
#ifdef _WIN64
typedef unsigned __int64 long_u;
typedef __int64 long_i;
# if defined(__GNUC__) && !defined(__clang__)
# define SCANF_HEX_LONG_U "%zx"
# define SCANF_DECIMAL_LONG_U "%zu"
# define PRINTF_HEX_LONG_U "0x%zx"
# else
# define SCANF_HEX_LONG_U "%Ix"
# define SCANF_DECIMAL_LONG_U "%Iu"
# define PRINTF_HEX_LONG_U "0x%Ix"
# endif
#else
// Microsoft-specific. The __w64 keyword should be specified on any
typedefs
// that change size between 32-bit and 64-bit platforms. For any
such type,
// __w64 should appear only on the 32-bit definition of the typedef.
// Define __w64 as an empty token for everything but MSVC 7.x or later.
# if !defined(_MSC_VER) || (_MSC_VER < 1300)
# define __w64
# endif
typedef unsigned long __w64 long_u;
typedef long __w64 long_i;
# define SCANF_HEX_LONG_U "%lx"
# define SCANF_DECIMAL_LONG_U "%lu"
# define PRINTF_HEX_LONG_U "0x%lx"
#endif
#define PRINTF_DECIMAL_LONG_U SCANF_DECIMAL_LONG_U
</snip>
Cheers
John