Tag: ifdefine

在Windows和Linux上编译C ++:ifdef switch

我想在Linux和Windows上运行一些c ++代码。 有一些代码我只想包括一个操作系统,而不是其他的。 有没有一个标准的#ifdef曾经可以使用? 就像是: #ifdef LINUX_KEY_WORD … // linux code goes here. #elif WINDOWS_KEY_WORD … // windows code goes here. #else #error "OS not supported!" #endif 这个问题确实是重复的,但这里的答案要好得多,尤其是被接受的答案。