這是我第一次嘗試編寫任何在C++中稍微複雜的東西,我試圖構建一個共享庫,我可以從Objective-C和.NET應用程序(好吧,這部分是後話......)編寫跨平臺的C++代碼(Windows,Linux和Mac OSX)
我的代碼是 -
#ifdef TARGET_OS_MAC
// Mac Includes Here
#endif
#ifdef __linux__
// Linux Includes Here
#error Can't be compiled on Linux yet
#endif
#ifdef _WIN32 || _WIN64
// Windows Includes Here
#error Can't be compiled on Windows yet
#endif
#include <iostream>
using namespace std;
bool probe(){
#ifdef TARGET_OS_MAC
return probe_macosx();
#endif
#ifdef __linux__
return probe_linux();
#endif
#ifdef _WIN32 || _WIN64
return probe_win();
#endif
}
bool probe_win(){
// Windows Probe Code Here
return true;
}
int main(){
return 1;
}
我有一個編譯器警告,只需untitled: In function ‘bool probe()’:untitled:29: warning: control reaches end of non-void function
- 但我也真的很感激任何信息或資源人們可以建議如何更好地編寫這種代碼...
你對WIN32的定義是正確的... – Goz 2010-09-02 12:57:59