可移植性库/框架

发布于 2024-10-09 00:56:54 字数 196 浏览 0 评论 0原文

我有《编写可移植代码》一书,其中详细介绍了 POSH,一个开源“框架”(主要只是一个标头)以帮助 C/C++ 代码在不同平台和硬件之间的可移植性。

由于 Poshlib 已经 5 年没有更新了,我想知道还有哪些其他类似的库/框架?

I have the book "Write Portable Code" which details POSH, an open-source "framework" (mostly just a header) to help with portability of C/C++ code between different platforms and hardware.

Since Poshlib hasn't had an update in 5 years now, I was wondering what other similar libraries/frameworks exist out there?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

圈圈圆圆圈圈 2024-10-16 00:56:55

对于 C 代码,GLib 是一个现代的跨平台(非 GUI)库,可以轻松编写在许多不同平台上运行的应用程序,而无需更改源代码。 GLib 作为 GNOME 项目的一部分以开放的方式积极开发,有许多开源项目使用它。

对于 C++,我建议查看 Boost 库。

For C code, GLib is a modern cross-platform (non-GUI) library which makes it easy to write applications that run on many different platforms without source code changes. GLib is actively developed in an open manner as part of the GNOME project with lots of open source projects using it.

For C++ I would suggest looking at the Boost libraries.

雪花飘飘的天空 2024-10-16 00:56:55

亲爱的毛茸茸的青蛙,
虽然我对你的处理方式仍然不感兴趣,但我必须说这是一个棘手的问题。原因如下。我日复一日地与 boost 库一起工作。它们非常棒,可以让无数任务变得更容易。但我必须强调,如果您使用它们,则需要使用分析器。它的一些非常好的部分往往有点慢,在使用某些部分(例如变换迭代器)之前,您绝对应该阅读最佳实践。不过,Boost 值得一提,因为它确实努力提供一些非常强大的抽象部分,而这些抽象部分在 ++ 领域几乎是陌生的。

然而,Boost 和其他类似的框架并不是万金油。他们摇滚。摇滚的人都使用它们。那些摇滚的人在他们身上工作。对于更专业的任务,我需要更多地了解您的问题领域。然而,另一个非常优秀的工具是 SWIG,它可以让您将任何大量可移植 C 代码捆绑到一个......很好......可访问的库中。

至于膨胀,当 C++0x 转向标准时,由于可变参数模板和许多类似的聪明才智,很多膨胀都会消失。老实说,我厌倦了人们大喊“模板的恐怖”。也许六年前,由于编译器支持不佳,它们是一种危险,但现在,它们已成为语言的一部分。它们几乎存在于您接触的每一段通用代码之下。就在我们说话之际,像 CLang 这样的项目正在为这口棺材敲下最后一颗钉子。它们不再是一种时尚。它们并不是一个神奇的解决方案。没有人仍然这么认为。不管怎样,你不应该雇用任何人。

未来即将到来。您需要增强吗?

Dear Shaggy Frog,
While I remain largely incurious about your handle, I must say that this is something of a hairy issue. Here's why. I work with the boost libraries day in and day out. They're fantastic, and make innumerable tasks way easier. But I must emphasis that if you use them, you need to use a profiler. Some of the really nice portions of it tend to be a bit slow, and you should definitely read up on best-practices before using certain parts like, say, transform iterators. Boost, though, is worth mentioning because it does make an effort to supply some pretty powerful pieces of abstraction that are almost foreign in the ++cverse.

However, Boost, and other frameworks like it, are not snakeoil. They rock. People who rock use them. People who rock work on them. For more specialized tasks, I'd need to know more about your problem domain. However, one other tool that's really excellent is SWIG, which will let you bundle up any hunk of portable C code into a library that's... well.... accessible.

As for bloat, a lot of that is going to go away when C++0x moves to the standard, thanks to variadic templates, and a number of similar pieces of cleverness. Honestly, I'm tired of people yelling about The Terrors Of Templates. Perhaps six years ago they were a danger due to poor compiler support, but these days, they're part of the language. They live under almost every piece of generic code you touch. Projects like CLang are hammering the very last nails into this coffin as we speak. They aren't a fad anymore. They aren't a magical solution. No one still thinks that. No one you should hire, anyway.

The future approaches. Do you need a Boost?

醉生梦死 2024-10-16 00:56:55

大多数名称中带有流行语“可移植框架”或“可移植运行时”的库都是无用的膨胀和万金油。如果您想编写可移植代码,请从相关标准开始并遵循它们。不要阅读供应商的手册页或标准库函数的帮助文件,而是阅读 ISO C 或 C++ 标准或 POSIX 标准。等等。

除了高度瘫痪的嵌入式系统(注意:许多/大多数嵌入式系统不属于“高度瘫痪”类别)和 DSP 之外,几乎任何环境都可以符合 POSIX 标准。比尝试在不同且不兼容的底层系统之上设计或找到新的“可移植性框架”更好的方法是评估完成工作需要 POSIX 的哪些部分,系统上可能缺少哪些部分或不符合要求您感兴趣的是,是否有针对缺失或损坏功能的直接替代品或解决方法。

对于大多数人来说,唯一相关的非 POSIX 系统是 Windows。 Cygwin 是使 Windows 符合 POSIX 的一个重量级选项,但如果您针对 POSIX 的更具包容性的子集进行编码,则可以使用更轻量级的解决方案,并且仍然支持 Windows。

Most libraries with the buzzwords "portability framework" or "portable runtime" in their names are useless bloat and snake oil. If you want to write portable code, start with the relevant standards and follow them. Instead of reading your vendor's man pages or help files for standard library functions, read the ISO C or C++ standard or POSIX standard. And so on.

Aside from highly crippled embedded systems (note: many/most embedded systems do not fall into the "highly crippled" category) and DSPs, pretty much any environment can be made to be POSIX conformant. A much better approach than trying to design or find a new "portability framework" on top of diverse and incompatible underlying systems is to evaluate what parts of POSIX you need to get the job done, what parts might be missing or non-conformant on systems you're interested in, and whether there are drop-in replacements or workarounds for the missing or broken functionality.

For most people, the only relevant non-POSIX system is Windows. Cygwin is one heavy-weight option for making Windows conform to POSIX, but if you code to a more-inclusive subset of POSIX, you can get by with much lighter solutions and still support Windows.

如梦初醒的夏天 2024-10-16 00:56:55

sourceforge 上有类似的 Predef 项目,但也已经好几年没有更新了。

There is similar Predef project on sourceforge, but it are not updated for several years also.

著墨染雨君画夕 2024-10-16 00:56:55

FWIW,预定义页面得到积极维护,并在过去几年中不断更新。

FWIW, the predef pages are actively maintained and have been continuously updated over the last several years.

澉约 2024-10-16 00:56:55

除了所有 C++ 程序员都应该熟悉的 Boost 之外,还有几个库值得一看。 STLSoft 是我第一个想到的。

Aside from Boost, which all C++ programmers should be familiar with, there are several libraries worth looking at. STLSoft is the first one that comes to my mind.

〆凄凉。 2024-10-16 00:56:55

我已经为我的 C 和 C++ 准备了一些著名的可移植性库的列表个人网站。人们可以根据知识共享归属许可证的条款自由地重复使用它。我对 Qt、GLib 和 Apache Portable Runtime 有一些经验,它们似乎都还不错。

维基百科上还有另一个列表

I have prepared a list of some prominent portability libraries for C and C++ on my personal web site. One can freely reuse it under the terms of the Creative Commons Attribution Licence. I had some experience with Qt, GLib, and the Apache Portable Runtime, and they all seemed to have been mostly OK.

There is also another list on the wikipedia.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文