我正在尝试在Arduino上使用Supermodified Servo。目前我的代码中没有实际的代码,我只是在尝试编译库时出现了很多错误。
经过一些研究,我发现如果将我的代码编译为C而不是C ++,我就不会得到这些错误。但我不知道如何做到这一点!
我正在使用适用于Linux x64的Arduino 1.0。
@Omnifarious 我的arduino草图中只有#include指令,目前是sketch_jan20.cpp
我添加了
#ifd __cplusplus{
extern "C"
#endif
除了一个问题之外,这有助于解决下面的错误:布尔值的重新定义。当我注释掉那一行时,出现了许多新的错误。所有的错误都是相同的,包括以下变化的某种形式:
C:\Users\Ventrius\Programming\Arduino1.01\libraries\ArduinoApiC\/zoCommands.h:131: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'zoCommandDoMove'
错误信息:
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/ArduinoApiC /tmp/build3069866408398264713.tmp/sketch_jan20a.cpp -o/tmp/build3069866408398264713.tmp/sketch_jan20a.cpp.o
In file included from /usr/share/arduino/libraries/ArduinoApiC/zoSmsMaster.h:4:0,
from sketch_jan20a.cpp:1:
/usr/share/arduino/libraries/ArduinoApiC/zoTypes.h:39:18: error: redeclaration of C++ built-in type ‘bool’
In file included from /usr/share/arduino/libraries/ArduinoApiC/zoSmsMaster.h:5:0,
from sketch_jan20a.cpp:1:
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:19:29: error: non-local function ‘void zoErrorInit(volatile ZO_ERROR*)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:20:27: error: non-local function ‘u08 zoErrorGet(volatile ZO_ERROR*)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:21:44: error: non-local function ‘void zoErrorPut(volatile ZO_ERROR*, u08)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:22:32: error: non-local function ‘bool zoErrorIsEmpty(volatile ZO_ERROR*)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:24:30: error: non-local function ‘u08 zoErrorGetIsr(volatile ZO_ERROR*)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:25:47: error: non-local function ‘void zoErrorPutIsr(volatile ZO_ERROR*, u08)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
In file included from /usr/share/arduino/libraries/ArduinoApiC/zoSmsMaster.h:6:0,
from sketch_jan20a.cpp:1:
/usr/share/arduino/libraries/ArduinoApiC/zoProtocol.h:93:26: error: non-local function ‘bool zoProtocolCommandResponse(ZO_PROTOCOL_HAL*, ZO_PROTOCOL_PACKET*, volatile ZO_ERROR*)’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: error: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
In file included from sketch_jan20a.cpp:1:0:
/usr/share/arduino/libraries/ArduinoApiC/zoSmsMaster.h:55:18: warning: non-local variable ‘volatile ZO_ERROR* zoSmsMasterError’ uses anonymous type
/usr/share/arduino/libraries/ArduinoApiC/zoError.h:15:2: warning: ‘typedef volatile struct<anonymous> ZO_ERROR’ does not refer to the unqualified type, so it is not used for linkage
.cpp
文件里只有包含指令,没有其他内容。 - Omnifarious.c
而不是.cpp
,并使用avr-gcc
进行编译。这样就能正常工作了。用extern "C"
包装你的#include
是错误的做法。Arduino似乎有一个C++接口,你为什么要#include
那个特定的文件呢? - Omnifarious