Arduino: Can import library in ino, but not in C++

拜拜、爱过 提交于 2019-12-13 00:43:57

问题


I'm trying to use a UTFT library in Arduino. If I work with a single .ino file and include the library there, everything works fine, like this:

example.ino

#include <UTFT.h>
UTFT myGLCD(QD220A,A2,A1,A5,A4,A3); 
...

However, if I create a .cpp and a .h file, like this:

example.h

#include <UTFT.h>

example.cpp

#include "example.h"
UTFT myGLCD(QD220A,A2,A1,A5,A4,A3); 
...

I get an error: UTFT does not mean a type

If I copy the whole TFT library to the project directory, and use #include "UTFT.h" in the example.h instead, the error is dismissed.

Why does this happen and how can I fix it?


回答1:


That's some of the magic of the Arduino IDE.

Are you using 1.0.6 or the beta 1.5.X?

Those kind of issues are being discussed on the google group and should be fixed in a near future.

In the meantime, you can give a try to the Bare Arduino Project.

The idea is to move away from the IDE, organise your project as you wish and use your favorite text editor such as vim or sublimetext with code completion and error checking.

If you have any issue using it, feel free to fill out an issue on Github ;)



来源:https://stackoverflow.com/questions/27630792/arduino-can-import-library-in-ino-but-not-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!