-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
root source file has no member called 'main' when WinMain is defined. #3712
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
Comments
To my knowledge this is a show stopper for Windows development for any instance where WinMain's function parameters are required. |
This problem continues to persist in build 0.5.0+008e42f48 (12/07/2019). Minimal repo. usingnamespace @import("std").os.windows;
export stdcallcc fn WinMain(hInstance: ?HINSTANCE, hPrevInstance: ?HINSTANCE, lpCmdLine: ?LPWSTR, nShowCmd: INT) INT {
return 0;
} |
|
I thought exporting implied the function was public? Where are the rules on that? Easy and confusing situation to get oneself in either case, so I think Zig would warn more helpfully in this situation, which I'm sure is going to continue to happen as Zig grows more alluring to win32 devs. |
I agree it's a bit counter intuitive at the moment. This area of the language is unstable. #1717 is accepted. That will probably encourage reconsidering #181, so that something as common as defining a function is not tedious. There is also #661.
let foo = fn (hInstance: ?HINSTANCE, hPrevInstance: ?HINSTANCE, lpCmdLine: ?LPWSTR, nShowCmd: INT) callconv(.stdcallcc) INT {
return 0;
}
comptime {
@export("WinMain", foo, .Strong);
} It's also possible for the root source file to import a different file which actually does the export of WinMain. The start code does not have access to find out what is or isn't exported, and it's using So, for now, the thing to do is slap a |
@andrewrk Did you considered about adding builtin |
On Zig 0.5.0+a11da3773.
zig build-exe ../src/test.zig --subsystem windows
C:\dev\Zig\lib\zig\std\special\start.zig:227:35: error: root source file has no member called 'main'
Interestingly, the error is only prompted if stdcallcc is not provided, but it's required otherwise the parameters are not accessible to the function as the calling convention is not observed.
If main() is defined then WinMain() is never called.
The text was updated successfully, but these errors were encountered: