Can we use wmain() functions with Unix compilers or it'll work only on windows?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 08:20:43

问题


Can we use wmain() functions with Unix compilers or it'll work only on\for windows?


回答1:


The only standard signatures for main are:

int main(void);
int main(int argc, char *argv[]);

However, a freestanding implementation can provide extensions/allow other signatures. But those are not guranteed to be portable. wmain looks like a Windows/VS thing. There's not much chance this will work on a *nix/GNU GCC.




回答2:


The wmain signature exists in Windows to handle wide-character command line arguments. Generally, while Windows applications prefer UTF16, Unix applications prefer UTF8 for Unicode string encoding. UTF8 uses regular char character strings, so the standard main signature suffices for Unicode-aware Unix appications.

If you want to make a portable console application that does not require Unicode command line parameters, use main. If you do need Unicode command line parameters, then you need preprocessor directives that will enable the signature appropriate to each environment.

If you are making a cross-platform GUI application, use a special framework, like QT.




回答3:


wmain() is windows-specific. Just like _tmain, if that matters...



来源:https://stackoverflow.com/questions/2438297/can-we-use-wmain-functions-with-unix-compilers-or-itll-work-only-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!