问题描述
在此评论的:
在编译C ++ code为,能用虚函数,异常,等等?或者你想在)?
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:你可以使用的虚函数和异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!