so we can compile
& then run it both in unix-like & windows platforms
But the answer really depends on what Linux required. From the Windows point of view, it's achievable if you include the WinMain stub I proposed above. That's how the cross-platform GUI toolkits Qt, wxWidgets, and FLTK do it.
Of course, you need a suitable #if test:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifdef _WINDOWS
// TODO
// For some reason or other Microsoft only provide the Unicode version
// of this function:
// CommandLineToArgvW function
// http://msdn.microsoft.com/en-us/library/bb776391%28VS.85%29.aspx
LPSTR* CommandLineToArgv(LPCSTR lpCmdLine, int *pNumArgs);
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)
{
int argc = 0;
char* argv = CommandLineToArgv(lpCmdLine, &argc);
return main(argc, argv);
}
#endif // _WIN32
@Andy
thanks for your answer.
but as i already told i want program to be independent from any programing kind or way (like WinAPI or gtk+ or etc) or from their libraries.
i already told i want program to be independent from any programing kind or way
I mentioned earlier that this is not possible. You code specifically for different OSs in different #if guards like andy said.
1 2 3 4 5 6 7 8 9
#ifdef _WIN32
//do what is required for windows
#endif
#ifdef __linux__
//do what is required for linux
#endif
#ifdef __APPLE__
//OS x machines...
#endif
As others have said, the best you can probably do is use something like Qt or other similar GUI framework. Have one set of code which you can cross compile to whichever platform you want.
If all you want is the source code for ShowWindow, then WHY? Just use the function.
Actually, it's not totally impossible. If you become a Most Valuable Professional (MVP) then it is possible obtain the right to access the Windows source code.