有Arduino的IDE一套编译器警告错误 [英] Have Arduino IDE set compiler warnings to error

查看:246
本文介绍了有Arduino的IDE一套编译器警告错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来设置编译器警告是PTED作为Arduino的IDE错误间$ P $?结果
或任何常规的方式来设置GCC编译器选项?

Is there a way to set the compiler warnings to be interpreted as an error in the Arduino IDE?
Or any generic way to set gcc compiler options?

我已经看过了〜/ .arduino / preferences.txt 却一无所获,表明微调的控制。我也看了,如果我可以通过设置环境变量gcc的选项,但没有发现任何东西。

I have looked at the ~/.arduino/preferences.txt but found nothing that indicates fine tuned control. I also looked if I could set gcc options via environment variables, but did not find anything.

我不希望有详细的编译器输出(可以指定使用IDE),它是太多分心非必要的信息,我不想浪费我的时间就通过它阅读。我要的是一个汇编停止在一个警告,所以code可以清理。我的preference将能够设置 = -Werror 选项,但一般的 -Werror 将尽为 .ino 项目的小code尺寸。

I don't want to have verbose compiler output (which you can specify using the IDE) that is way too much distracting non-essential information, I don't want to waste my time on reading through it. What I want is for a compilation to stop on a warning, so code can be cleaned up. My preference would be to be able to set -Werror= options, but a generic -Werror will do for the small code size of .ino projects.

附录:

根据所选答案的建议,我实现了一个 AVR-G ++ 脚本,并将该路径正常 AVR-G ++之前。对于我改变了Arduino的命令如下:

Based on the suggestion in the selected answer, I implemented an avr-g++ script and put that in the path before the normal avr-g++. For that I changed the arduino command as follows:

-export PATH="${APPDIR}/java/bin:${PATH}"
+export ORGPATH="${APPDIR}/java/bin:${PATH}"
+export PATH="${APPDIR}/extra:${ORGPATH}"

和在新目录额外的在APPSDIR(其中Arduino的命令所在),我有
一个 AVR-G ++ 这是一个Python脚本:

and in the new directory extra in the APPSDIR (where the arduino command is located), I have an avr-g++ which is a Python script:

#!/usr/bin/env python

import os
import sys
import subprocess

werr = '-Werror'
wall = '-Wall'

cmd = ['avr-g++'] + sys.argv[1:]
os.environ['PATH'] = os.environ['ORGPATH']
fname = sys.argv[-2][:]
if cmd[-2].startswith('/tmp'):
    #print fname, list(fname) # this looks strange
    for i, c in enumerate(cmd):
        if c == '-w':
            cmd[i] = wall
            break
    cmd.insert(1, werr)
subprocess.call(cmd)

所以,你用一部开拓创新的编译器的名称替换第一个命令和复位用于不包括环境额外目录。

FNAME 实际上是奇怪,如果你打印只有 abc.cpp ,但其长度大得多它实际上与 / tmp目录启动。所以,我检查,要决定是否添加/更新的编译选项。

The fname is actually strange, if you print it is only abc.cpp but its length is much larger and it actually starts with /tmp. So I check for that to decide whether to add/update the compile options.

推荐答案

看起来像你在Linux上。 Arduino是一个脚本,这样你就可以在脚本中设置PATH以包括开头目录包含一个程序AVR-G ++的目录。那么Java的东西应该采取的编译器从那里,它应该没有。

Look like you on Linux. arduino is a script, so you can set PATH in the script to include a dir at beginning to a directory containing a program avr-g++. Then the java stuff should take compiler from there, should it not.

这程序然后调用标准/ usr / bin中/ AVR-G ++与额外的选项。

That program then calls the normal /usr/bin/avr-g++ with the extra options.

我还没有尝试过自己,让我知道,如果你这样做是否可行。

I have not tried myself, let me know if you do if that works.

这篇关于有Arduino的IDE一套编译器警告错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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