如何规避 Symbian 命名约定?

发布于 2024-07-30 18:16:09 字数 473 浏览 2 评论 0原文

我即将编写一个 C++ 库,供 Windows 应用程序以及 Symbian 上的应用程序使用。 Linux 不是当前的要求,但通常也是可能的。
因此,我想使用 STL/Boost 命名约定,而不是 Symbian 的,我认为很难习惯。
当使用 Carbide.c++ 编译代码时,这似乎已经出现了问题,因为它强制执行 Symbian 命名约定。

如何使用“正常”名称并仍然兼容 Symbian? 我首先考虑有条件地重新定义 Symbian 平台的类名,但我担心这会导致混乱。

不遵守Symbian的命名约定会不会出现其他问题?

I'm about to write a C++ library that is to be used by a Windows application as well as on Symbian. Linux is not a current requirement but should generally be possible, too.
For this reason I would like to use the STL/Boost naming conventions instead of Symbian's, which I think, are hard to get used to.
This seems to already present a problem, when compiling the code with Carbide.c++ as it enforces the Symbian naming convention.

How can I use "normal" names and still be Symbian compatible?
I first thought about conditionally re-#define-ing class names for the Symbian platform but I fear, that this will lead to confusion.

Could there occur other problems by not complying with Symbian's naming convention?

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

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

发布评论

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

评论(1

蓝眼泪 2024-08-06 18:16:09

编码约定并不严格。 它们的存在是为了让我们人类更容易理解代码。 如果您正在编写一个多平台库,请随意使用您喜欢的任何约定。

当然,您的库可能需要以某种方式与底层操作系统进行交互。 借助开放 C/C++ 库,您可以做很多事情无需使用本机 Symbian C++ API 及其命名约定。

在 Carbide.c++ 中,您可能想要禁用 CodeScanner 静态分析,因为它实际上只对用本机 Symbian C++ 编写的代码有用。

总而言之,问题如下:

  • 来自本机 Symbian C++ 背景的人不会立即熟悉您的约定
  • 使用本机 Symbian C++ API 可能会暴露一些特定于平台的特性(异常与叶子、陷阱线束、活动调度程序等)
  • Symbian 特定的静态分析器(例如 CodeScanner)采用 Symbian C++ 代码风格,并且可能会生成您实际上不需要关心的错误/警告

Coding conventions are not strict. They are there to make understanding code easier for us humans. If you're writing a multi-platform library, feel free to use whatever convention you are comfortable with.

Of course, your library probably needs to interface with the underlying operating system in some ways. With the help of Open C/C++ libraries, you can do many things without needing to use native Symbian C++ APIs and their naming conventions.

In Carbide.c++ you may want to disable CodeScanner static analysis as it is really only useful to code written in native Symbian C++.

So in summary, the problems are as follows:

  • People coming from native Symbian C++ background are not immediately familiar with your conventions
  • Using native Symbian C++ APIs can expose some platform-specific peculiarities (exceptions vs. leaves, trap harnesses, active schedulers etc.)
  • Symbian-specific static analyzers such as CodeScanner assume Symbian C++ code style and may generate errors/warnings you really don't need to care about
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文