Skip to content

Pick up WinMain with proper CC #3733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2019
Merged

Conversation

LemonBoy
Copy link
Contributor

Closes #3712

@daurnimator daurnimator added the stage1 The process of building from source via WebAssembly and the C backend. label Nov 20, 2019
@daurnimator
Copy link
Contributor

Could we add a regression test?

@LemonBoy
Copy link
Contributor Author

Could we add a regression test?

That's an exercise left to the reader :) You need some os-detection tricks to have a portable test case.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async calling convention should be a compile error here, with a new test case in test/compile_errors.zig

add_fn_export implementation is wrong; it should be looking for stdcallcc rather than ccc to decide whether to check for these special Windows functions. The parameter should be changed from bool ccc to CallingConvention cc, and the function should look for CallingConventionStdcall.

This is all assuming that WinMain & friends are supposed to be stdcallcc and not ccc, which appears to be the case.

@JesseRMeyer
Copy link

This is all assuming that WinMain & friends are supposed to be stdcallcc and not ccc, which appears to be the case.

MSDN is inconsistent on this, but WINAPI is typedef'd to __stdcall on VS2019's version of Windows.h, which qualifies WinMain (and friends).

https://docs.microsoft.com/en-us/cpp/cpp/stdcall?redirectedfrom=MSDN&view=vs-2019

'The __stdcall calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes vararg functions __cdecl. Functions that use this calling convention require a function prototype.'

@andrewrk andrewrk merged commit fd7c7be into ziglang:master Dec 3, 2019
@andrewrk
Copy link
Member

andrewrk commented Dec 3, 2019

Thanks for the follow-up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

root source file has no member called 'main' when WinMain is defined.
4 participants