如何使用 C++11 对 Arduino 进行编程? [英] How can I use a C++11 to program the Arduino?

查看:54
本文介绍了如何使用 C++11 对 Arduino 进行编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在对 Arduino 进行编程时使用 C++11?

How can I use C++11 when programming the Arduino?

我可以使用 Arduino IDE 或其他环境.我最感兴趣的是核心语言的改进,而不是需要更改标准库的东西.

I would be fine using either the Arduino IDE or another environment. I am most interested in the core language improvements, not things that require standard library changes.

推荐答案

1.6.6 版开始,Arduino IDE 默认启用 C++11.

As of version 1.6.6, the Arduino IDE enables C++11 by default.

对于旧版本,请继续阅读:

For older versions, read on:

很容易更改工具链中任何元素的标志包括汇编器、编译器、链接器或归档器.

在 Arduino IDE 1.5.7 版(2014 年 7 月发布)上测试,

Tested on the Arduino IDE version 1.5.7 (released on July 2014),

  1. 找到 platform.txt 文件,

  • AVR 架构 =>{安装路径}\hardware\arduino\avr\platform.txt
  • SAM 架构 =>{安装路径}\hardware\arduino\sam\platform.txt
    1. 在该文件中,您可以更改任何标志,例如,

    • compiler.c.flags 用于更改 C++ 文件的默认编译标志.
    • compiler.cpp.flags 用于更改 C++ 文件的默认编译标志.
      • compiler.c.flags for changing the default compilation flags for C++ files.
      • compiler.cpp.flags for changing the default compilation flags for C++ files.
        1. 您还可以更改任何食谱"或编译模式,在配置文件的相应部分,在标题AVR/SAM 编译模式"下.
        2. 进行更改后,您必须重新启动 Arduino IDE,至少在 1.5.7 版上.
        1. You can also change any of the "recipes" or compile patters, at the corresponding section of the configuration file, under the title "AVR/SAM compile patterns".
        2. After making the changes, you must restart the Arduino IDE, at least on version 1.5.7.

        例如

        要启用对 C++11 (C++0x) 的支持,在 Arduino IDE 版本 1.5.7 和 1.5.8 上测试,您只需添加标志-std=gnu"++11"在以 compiler.cpp.flags=".

        To enable support for C++11 (C++0x), tested on Arduino IDE versions 1.5.7 and 1.5.8, you will simply add the flag "-std=gnu++11" at the end of the line starting with compiler.cpp.flags=".

        预计在不久的将来在 Arduino IDE 上默认启用 C++11.但是,从 1.5.8 版(2014 年 10 月)开始,情况仍然不是这样.

        It is expected that C++11 is enabled by default in the near future on the Arduino IDE. However, as of version 1.5.8 (Oct 2014) it is still not the case.

        这篇关于如何使用 C++11 对 Arduino 进行编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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