Arduino的C ++ code:你可以使用的虚函数和异常? [英] Arduino C++ code: can you use virtual functions and exceptions?

查看:412
本文介绍了Arduino的C ++ code:你可以使用的虚函数和异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此评论的编写固件:组装或高级别

在编译C ++ code为的Arduino平台,能用虚函数,异常,等等?或者你想在描述的(得)用C的一个子集++(评论)?

When compiling C++ code for the Arduino platform, can you use virtual functions, exceptions, etc? Or would you want to (have to) use a subset of C++ (as described in the comment)?

当编程为平台的Arduino任何其他注意事项?

Any other caveats when programming for the Arduino platform?

推荐答案

Arduino的环境使用GCC工具链的AVR版本。在code编译为C ++,所以你可以使用类。虚拟函数是可能的;所述的vtables将存储在.data段和具有正确的地址。事实上,打印基类中使用虚函数的各种打印方法,以适应不同的输出类型。

The Arduino environment uses the AVR version of the GCC toolchain. The code is compiled as C++, so you can use classes. Virtual functions are possible; the vtables will be stored in the .data section and have the correct addresses. In fact, the Print base class uses virtual functions to adapt the various "print" methods to the different output types.

例外是不是因为code空间的原因支持。 Arduino的环境通过-fno-例外编译器命令行。请参见对于此验证。

Exceptions are not supported because of code space reasons. The Arduino environment passes "-fno-exceptions" to the compiler command line. See the source for verification of this.

模板支持。例如,这种无成本的流插入运算技术使用一个简单的模板,并内嵌运营商的正常工作。

Templates are supported. For example, this no-cost stream insertion operator technique works fine using a simple template and inline operator.

这篇关于Arduino的C ++ code:你可以使用的虚函数和异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆