1、C++ 通过宏定义判定当前操作系统
#includeusing namespace std; // 主函数 int main(int argc, char *argv[]) { #ifndef _WIN32 cout << "当前系统: Window 32 位" << endl; #else cout << "当前系统: Window 64 位" << endl; #endif // !(_WIN32_) return 0; }
调试结果

1、C++ 通过宏定义判定当前操作系统
#includeusing namespace std; // 主函数 int main(int argc, char *argv[]) { #ifndef _WIN32 cout << "当前系统: Window 32 位" << endl; #else cout << "当前系统: Window 64 位" << endl; #endif // !(_WIN32_) return 0; }
调试结果