Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Can we use the wmain() function with Unix compilers or it'll work only on/for Windows?

like image 233
Rella Avatar asked Mar 13 '10 12:03

Rella


2 Answers

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.

like image 127
Don Reba Avatar answered Oct 22 '22 05:10

Don Reba


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.

like image 35
dirkgently Avatar answered Oct 22 '22 07:10

dirkgently