0 Members and 1 Guest are viewing this topic.
Maybe it's the easyest to detect the platform, and make a function for every platform
#include <windows.h>using namespace std;void main(){ ShellExecute(NULL, "open", "http://www.thebest404pageever.com/swf/index.php", NULL, NULL, SW_SHOWNORMAL);}
Quote from: ben_g on May 14, 2011, 04:48:43 pmMaybe it's the easyest to detect the platform, and make a function for every platformWell, there are lots of platforms (Windows, Linux, Mac, Solaris) and I hope there's a way to do this.In Python, webbrowser.open("url") will open in the default browser on any platform so I guess there is a way to do that in C/C++.
That's because Python gets interpreted the same way, remember. C++ is compiled to assembly, which is different on each OS. I don't think there's a real cross-platform way to do it. Since you're going to have to release separate versions for each platform anyway (you can't release an .exe for Mac users, for instance) what about keeping different versions for each? I think that's what most devvers do.I don't know C++ though, so I might be wrong.
just make for windows or Linux for now, and later do it hardcore by using '#ifdef', '#elseif', '#endif' expressions to keep it as one source file And, for start, windows:Code: [Select]#include <windows.h>using namespace std;void main(){ ShellExecute(NULL, "open", "http://www.thebest404pageever.com/swf/index.php", NULL, NULL, SW_SHOWNORMAL);}
I managed to open it, but only works in Linux. I found a Windows-only way too and can probably find a Mac too. Maybe I'll go with try blocks I don't know because it's impossible to find out the user OS during runtime.
Quote from: Scout on May 15, 2011, 07:28:41 amI managed to open it, but only works in Linux. I found a Windows-only way too and can probably find a Mac too. Maybe I'll go with try blocks I don't know because it's impossible to find out the user OS during runtime.You'll have to compile seperately anyway, so it'll be known at compile time.