gpt4 book ai didi

c++ - windows和linux之间的可移植代码

转载 作者:太空宇宙 更新时间:2023-11-03 10:35:23 25 4
gpt4 key购买 nike

我有一个为 linux 编写的应用程序,我也想让它在 windows 下执行。那么我怎样才能让特定的代码行只在程序运行在 windows 下时才执行呢?我知道它与#ifdef 相关...谢谢

最佳答案

您正在寻找:

#if defined(_WIN32)
// Your Windows specific code here
#endif

根据评论编辑:

此处对 _WIN32 与 WIN32 进行了很好的讨论:Whats the difference between the win32 defines

关于c++ - windows和linux之间的可移植代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4879525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com