Alexandre Julliard : winecrt0: Make the main() and wmain() entry points cdecl.

Ken Thomases ken at codeweavers.com
Mon Oct 21 18:56:13 CDT 2019


There may be a conflict between this and Clang.  I haven't observed any actual problem in practice, but have some familiarity with Clang's implementation.

Clang overrides the calling convention attributes on any "main" function at file scope, restoring it to the default C calling convention for the target.  It, of course, assumes it will be called by the target's C runtime, not Wine's.
<https://github.com/llvm/llvm-project/blob/15984457a673eff3969c0755be543e7d572edd47/clang/lib/Sema/SemaDecl.cpp#L10638>

-Ken

> On May 30, 2019, at 4:27 PM, Alexandre Julliard <julliard at winehq.org> wrote:
> 
> Module: wine
> Branch: master
> Commit: f2a7405a09c66e4b9adc15d4e9b7379ed4c78f54
> URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f2a7405a09c66e4b9adc15d4e9b7379ed4c78f54
> 
> Author: Alexandre Julliard <julliard at winehq.org>
> Date:   Thu May 30 10:24:19 2019 +0200
> 
> winecrt0: Make the main() and wmain() entry points cdecl.
> 
> Signed-off-by: Alexandre Julliard <julliard at winehq.org>
> 
> ---
> 
> dlls/winecrt0/exe_entry.c    | 2 +-
> dlls/winecrt0/exe_main.c     | 2 +-
> dlls/winecrt0/exe_wentry.c   | 2 +-
> dlls/winecrt0/exe_wmain.c    | 2 +-
> programs/wineboot/wineboot.c | 2 +-
> programs/winebrowser/main.c  | 2 +-
> programs/winedbg/winedbg.c   | 2 +-
> programs/winepath/winepath.c | 2 +-
> 8 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/dlls/winecrt0/exe_entry.c b/dlls/winecrt0/exe_entry.c
> index 60c11aa..69ebb1b 100644
> --- a/dlls/winecrt0/exe_entry.c
> +++ b/dlls/winecrt0/exe_entry.c
> @@ -27,7 +27,7 @@
> #include "wine/library.h"
> #include "crt0_private.h"
> 
> -extern int main( int argc, char *argv[] );
> +extern int __cdecl main( int argc, char *argv[] );
> 
> DWORD WINAPI DECLSPEC_HIDDEN __wine_spec_exe_entry( PEB *peb )
> {
> diff --git a/dlls/winecrt0/exe_main.c b/dlls/winecrt0/exe_main.c
> index 94a96d1..f51deba 100644
> --- a/dlls/winecrt0/exe_main.c
> +++ b/dlls/winecrt0/exe_main.c
> @@ -25,7 +25,7 @@
> #include "winbase.h"
> #include "winuser.h"
> 
> -int main( int argc, char *argv[] )
> +int __cdecl main( int argc, char *argv[] )
> {
>     STARTUPINFOA info;
>     char *cmdline = GetCommandLineA();
> diff --git a/dlls/winecrt0/exe_wentry.c b/dlls/winecrt0/exe_wentry.c
> index ed1bd20..83606f2 100644
> --- a/dlls/winecrt0/exe_wentry.c
> +++ b/dlls/winecrt0/exe_wentry.c
> @@ -27,7 +27,7 @@
> #include "wine/library.h"
> #include "crt0_private.h"
> 
> -extern int wmain( int argc, WCHAR *argv[] );
> +extern int __cdecl wmain( int argc, WCHAR *argv[] );
> 
> DWORD WINAPI DECLSPEC_HIDDEN __wine_spec_exe_wentry( PEB *peb )
> {
> diff --git a/dlls/winecrt0/exe_wmain.c b/dlls/winecrt0/exe_wmain.c
> index d697e90..f817462 100644
> --- a/dlls/winecrt0/exe_wmain.c
> +++ b/dlls/winecrt0/exe_wmain.c
> @@ -27,7 +27,7 @@
> 
> int WINAPI wWinMain(HINSTANCE,HINSTANCE,LPWSTR,int);
> 
> -int wmain( int argc, WCHAR *argv[] )
> +int __cdecl wmain( int argc, WCHAR *argv[] )
> {
>     STARTUPINFOW info;
>     WCHAR *cmdline = GetCommandLineW();
> diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
> index ac43f14..defd126 100644
> --- a/programs/wineboot/wineboot.c
> +++ b/programs/wineboot/wineboot.c
> @@ -1255,7 +1255,7 @@ static const struct option long_options[] =
>     { NULL,          0, 0, 0 }
> };
> 
> -int main( int argc, char *argv[] )
> +int __cdecl main( int argc, char *argv[] )
> {
>     static const WCHAR RunW[] = {'R','u','n',0};
>     static const WCHAR RunOnceW[] = {'R','u','n','O','n','c','e',0};
> diff --git a/programs/winebrowser/main.c b/programs/winebrowser/main.c
> index 7fcaba1..9cd6812 100644
> --- a/programs/winebrowser/main.c
> +++ b/programs/winebrowser/main.c
> @@ -425,7 +425,7 @@ static WCHAR *convert_file_uri(IUri *uri)
>  * Main entry point. This is a console application so we have a wmain() not a
>  * winmain().
>  */
> -int wmain(int argc, WCHAR *argv[])
> +int __cdecl wmain(int argc, WCHAR *argv[])
> {
>     static const WCHAR nohomeW[] = {'-','n','o','h','o','m','e',0};
> 
> diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c
> index 8634c0f..5aeaa0d 100644
> --- a/programs/winedbg/winedbg.c
> +++ b/programs/winedbg/winedbg.c
> @@ -662,7 +662,7 @@ static void restart_if_wow64(void)
>     }
> }
> 
> -int main(int argc, char** argv)
> +int __cdecl main(int argc, char** argv)
> {
>     int 	        retv = 0;
>     HANDLE              hFile = INVALID_HANDLE_VALUE;
> diff --git a/programs/winepath/winepath.c b/programs/winepath/winepath.c
> index ef11a5a..36881d3 100644
> --- a/programs/winepath/winepath.c
> +++ b/programs/winepath/winepath.c
> @@ -144,7 +144,7 @@ static int parse_options(WCHAR *argv[])
> /*
>  * Main function
>  */
> -int wmain(int argc, WCHAR *argv[])
> +int __cdecl wmain(int argc, WCHAR *argv[])
> {
>     LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR) = NULL;
>     LPWSTR (*CDECL wine_get_dos_file_name_ptr)(LPCSTR) = NULL;
> 
> 
> 




More information about the wine-devel mailing list