0
点赞
收藏
分享

微信扫一扫

cmake 处理与平台相关的源代码


​​代码在git​​

通过 cmake 宏定义来实现

#include <cstdlib>
#include <iostream>
#include <string>

std::string say_hello() {
#ifdef IS_WINDOWS
return std::string("Hello from Windows!");
#elif IS_LINUX
return std::string("Hello from Linux!");
#elif IS_MACOS
return std::string("Hello from macOS!");
#else
return std::string("Hello from an unknown system!");
#endif
}

int main() {
std::cout << say_hello() << std::endl;
return EXIT_SUCCESS;
}


举报

相关推荐

0 条评论