C++ 的哪些部分? Brew (MP) 是否支持?
您好,我正在尝试找出 BrewMP 上的 C++ 可以做什么、不可以做什么。
是否有人拥有在 Brew(特别是 BrewMP)中使用 C++ 的第一手经验,并且可以说他们是否设法让这些东西在设备上运行而没有太多麻烦:
- 静态变量/函数
- 模板
- 异常
- 转换 ETC。
Hi I'm trying to find out what is and isn't possible with C++ on BrewMP.
Does anybody have first hand experience of using C++ with Brew, specifically BrewMP, and can say if they have managed to get these things working on a device without too much hassle:
- static variables/functions
- templates
- exceptions
- casting
etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在Brew3.X之前,不支持全局变量和静态变量。但是在 Brew MP 中,有一个 ELF2MOD 工具。这样,您就可以使用全局变量和静态变量。
查看您的 SDK 路径,例如:
C:\Program Files\Qualcomm\Brew MP SDK\Toolset 7.10 Rev 10.0.1489821\bin
如果您的全局或静态数据是非 POD(C++ 对象,必须调用 C++ 类构造函数),请不要使用它。看
https://developer.brewmp.com/forum/using-static-variables -classes-0
BrewMP 中绝对禁止使用标准 C 库(stdc lib 或 c 运行时),例如 memset 和 sprintf。原因:在具有 main() 入口的通用进程模块中,C 运行时的那些进程在用户代码调用它们之前已经自动初始化。 BrewMP mod (mod1) 文件是动态加载和链接的。没有适当的时间来调用初始化,并且这些 MOD 不应单独调用 C 运行时初始化。
C++ 模板函数和模板类:模板代码实例化在编译时生成,不需要任何加载时和运行时代码初始化。它们可以在设备中安全地使用。
C++ 异常:我没有测试过。在默认的ARM编译器选项中,异常没有打开。并且异常需要C++ RTTI的启用。
C++强制转换:dynamic_cast是个大问题,因为它需要支持启用运行时类型识别,并在运行时进行类型检查。其他类型转换,例如 static_cast、reinterpret_cast 和 const_cast,只是编译器在编译时检查的提示。
Before in Brew3.X, global and static variables are not supported. However in Brew MP, there is an ELF2MOD tool. With this, you can use global and static varaibles.
See your SDK path such as:
C:\Program Files\Qualcomm\Brew MP SDK\Toolset 7.10 Rev 10.0.1489821\bin
If your global or static data is non-POD (a C++ object, which has to call C++ class constructor), please don't use it. See
https://developer.brewmp.com/forum/using-static-variables-classes-0
Standard C Library (stdc lib, or c runtime) are absolutely prohibited in BrewMP, such as memset and sprintf. Cause: In a general process module with main() entry, those of C runtime are already initialized automatically before user's code calling them. BrewMP mod (mod1) files are dynamically loaded and linked. There are no appropriate time to call initialization, and these MODs should not call C runtime initialization individually.
C++ template functions and template classes: template code instantiation are generted at compile-time, and they don't need any load-time and run-time code initialization. They can be used safely in device.
C++ Exceptions: I didn't tested it. In the default ARM compiler options, exception are not turned on. And the exceptions need the enablement of C++ RTTI.
C++ cast: dynamic_cast is the big problem, because it needs support run-time type identification enabled, and doing type checking at run time. Other casts, such as static_cast, reinterpret_cast, and const_cast, are only a hint for compiler to check at compile-time.
存在一些问题:
大多数对象
都可以使用自定义后链接器来解决。它对我来说效果很好,希望它也适合你。
There were some problems with:
objects
Most of them can be solved using custom post-linker. It worked fine for me, hope it`s suitable for you too.