[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unable to cross build for Windows
From: |
Martin Dorey |
Subject: |
Re: Unable to cross build for Windows |
Date: |
Fri, 9 Jun 2023 06:32:28 +0000 |
> in some MinGW64 header files?
Easily eliminated:
martind@sirius:~/tmp/svensson-2023-06-08$ cat make.c
#include <stdint.h>
intptr_t _get_osfhandle(int);
typedef void* HANDLE;
HANDLE fn() {
return (HANDLE)_get_osfhandle(0);
}
martind@sirius:~/tmp/svensson-2023-06-08$ gcc -c -Wbad-function-cast make.c
make.c: In function ‘fn’:
make.c:7:10: warning: cast from function call of type ‘intptr_t {aka long int}’
to non-matching type ‘void *’ [-Wbad-function-cast]
return (HANDLE)_get_osfhandle(0);
^
martind@sirius:~/tmp/svensson-2023-06-08$
That's gcc-6.3, but it's much the same in every version I tested from gcc-4.4
to gcc-10. A random version's man page,
https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Warning-Options.html, explains the
flag as to:
> Warn when a function call is cast to a non-matching type. For example, warn
> if a call to a function returning an integer type is cast to a pointer type.
I fear they mean exactly what they say there. So, while you might call it a
mistake, I don't think it's an accident.
https://stackoverflow.com/a/35308713/18096 has some explanation of why it might
sometimes be useful... and how it could be sidestepped by a change to Gnu Make,
like our new friend wished for.
- Unable to cross build for Windows, Torbjorn SVENSSON, 2023/06/08
- Re: Unable to cross build for Windows, Eli Zaretskii, 2023/06/08
- Re: Unable to cross build for Windows, Torbjorn SVENSSON, 2023/06/08
- Re: Unable to cross build for Windows, Eli Zaretskii, 2023/06/08
- Re: Unable to cross build for Windows, Torbjorn SVENSSON, 2023/06/08
- Re: Unable to cross build for Windows, Paul Smith, 2023/06/08
- Re: Unable to cross build for Windows, Eli Zaretskii, 2023/06/09
- Re: Unable to cross build for Windows,
Martin Dorey <=
- Re: Unable to cross build for Windows, Eli Zaretskii, 2023/06/09
- Re: Unable to cross build for Windows, Torbjorn SVENSSON, 2023/06/09
- Re: Unable to cross build for Windows, Paul Smith, 2023/06/09
- Re: Unable to cross build for Windows, Torbjorn SVENSSON, 2023/06/09