On 09-May-2020 21:06, Ken Takata wrote:
Hi John,
2020/5/9 Sat 16:30:42 UTC+9 John Marriott wrote:
Hi All,
After cleaning my vim source repo and rebuilding with the brand
new gcc
10.1 (mingw64), I get these warnings:
<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 "%Ix"
| ^~~~~
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
343 | # define SCANF_HEX_LONG_U "%Ix"
| ^~~~~
vim.h:343:36: note: format string is defined here
343 | # define SCANF_HEX_LONG_U "%Ix"
| ^
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 "%Ix"
| ^~~~~
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
343 | # define SCANF_HEX_LONG_U "%Ix"
| ^~~~~
vim.h:343:36: note: format string is defined here
343 | # define SCANF_HEX_LONG_U "%Ix"
| ~~^
| |
| unsigned int *
| %Illx
vim.h:344:33: warning: format '%u' expects argument of type 'unsigned
int *', but argument 3 has type 'long_u *' {aka 'long lo
ng unsigned int *'} [-Wformat=]
344 | # define SCANF_DECIMAL_LONG_U "%Iu"
| ^~~~~
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
344 | # define SCANF_DECIMAL_LONG_U "%Iu"
| ^~~~~
vim.h:344:36: note: format string is defined here
344 | # define SCANF_DECIMAL_LONG_U "%Iu"
| ~~^
| |
| unsigned int *
| %Illu
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
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/9ebb1b4f-0496-47ce-119c-3ba04a94fcf5%40internode.on.net.
--- vim.h.orig 2020-04-13 05:57:51.271454000 +1000
+++ vim.h 2020-05-10 06:06:04.301993000 +1000
@@ -340,9 +340,15 @@
#ifdef _WIN64
typedef unsigned __int64 long_u;
typedef __int64 long_i;
-# define SCANF_HEX_LONG_U "%Ix"
-# define SCANF_DECIMAL_LONG_U "%Iu"
-# define PRINTF_HEX_LONG_U "0x%Ix"
+# 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,