c++/c:从制造到cmake(Windows和Linux)迁移:平台特定的实现

发布于 2025-01-28 03:17:01 字数 436 浏览 3 评论 0原文

我目前正在将200万个C ++/C代码线的项目迁移到使用CMAKE的项目。大多数事情都非常直截了当,但是我似乎找不到实现以下内容的最佳实践:

内核库中的许多低级别(旧版)组件都使用编译器警卫以以下形式区分Linux和Windows实现:

#ifdef WINDOWS
// #include ...
#else
// #include ...
#endif

和/或:

void lowLevelFunction()
{
#ifdef WINDOWS
    // Windows implementation
    return;
#else
    // Linux implementation
    return;
#endif
}

在CMake或以某种方式委托上这样做有最好的做法吗?

谢谢

I'm currently migrating a project of 2 million C++/C code lines from Makefiles to using Cmake. Most things are pretty straight forward, but I can't seem to find the best practice to achieve the following:

Many low level (legacy) components in my kernel library use compiler guards to differentiate between the Linux and Windows implementations in the following form:

#ifdef WINDOWS
// #include ...
#else
// #include ...
#endif

and/or:

void lowLevelFunction()
{
#ifdef WINDOWS
    // Windows implementation
    return;
#else
    // Linux implementation
    return;
#endif
}

Is there a best practice to do this on Cmake or to somehow delegate?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文