When mingw-w64 is compiled with LTO support (-flto and -ffat-lto-objects in CFLAGS and LDFLAGS) then simple C application
int main(void) { return 0; } cause LTO compile warning: $ gcc test.c -o test.exe -flto ./include/internal.h:113:17: warning: type of ‘main’ does not match original declaration [-Wlto-type-mismatch] test.c:1:5: note: type mismatch in parameter 1 int main(void) { return 0; } ^ test.c:1:5: note: type ‘void’ should match type ‘int’ test.c:1:5: note: ‘main’ was previously declared here This is because internal.h defines main as: int __CRTDECL main(int _Argc, char **_Argv, char **_Env); Which does not match the main in test.c application. Function main is somehow special that it can take from zero to three parameters. So define it in internal.h file without parameters. This will mute the gcc LTO warning which is printed by default. Same applies for wmain() function. --- mingw-w64-crt/include/internal.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mingw-w64-crt/include/internal.h b/mingw-w64-crt/include/internal.h index 997a89b189a1..e68296a4123f 100644 --- a/mingw-w64-crt/include/internal.h +++ b/mingw-w64-crt/include/internal.h @@ -110,8 +110,11 @@ extern "C" { int __CRTDECL _wsetargv(void); int __CRTDECL __wsetargv(void); - int __CRTDECL main(int _Argc, char **_Argv, char **_Env); - int __CRTDECL wmain(int _Argc, wchar_t **_Argv, wchar_t **_Env); + /* Do not define main parameters because then it cause LTO compile + * warning (-Wlto-type-mismatch) about mismatches parameters when + * application defines main as: int main(void) { ... } */ + int __CRTDECL main(/*int _Argc, char **_Argv, char **_Env*/); + int __CRTDECL wmain(/*int _Argc, wchar_t **_Argv, wchar_t **_Env*/); #ifndef _STARTUP_INFO_DEFINED #define _STARTUP_INFO_DEFINED -- 2.20.1 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public