*NIX systems shouldn't spawn terminal windows by default, so you'll probably only have to do something special on Windows.
If you can wrap the WinMain function, that is, put #define
guards around it and call another function that acts as the "real" main
inside of it, and then call that function from main
on other platforms there should be no major issues.
However, I'd strongly suggest avoiding wide characters (wchar_t
) whereever possible because they differ from platform to platform and handling platform-specific API calls that need them by internally storing all strings as, for instance, UTF-8, converting them (For example via MultiByteToWideChar) only to make the API call.
Basically, non-Windows platforms will need you to use a standard main
function, Windows will need you to use WinMain
. Make them both call a third function that handles what your main function should and return.
Also, any Windows PE binary (.exe file) will only work on Windows. You'll have to compile your program for each platform separately regardless of what you do.