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

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

问题描述

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

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:

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

It is very easy to change the flags for any element of the toolchain, including the assembler, compiler, linker or archiver.

在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. 进行更改后,您必须至少在1.5.7版本上重新启动Arduino IDE .
        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.

        例如,

        要启用对Arduino IDE版本1.5.7和1.5.8进行测试的C ++ 11(C ++ 0x)的支持,只需添加标志"-std = gnu"++ 11";在此行的末尾,以compile.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天全站免登陆