I am currently trying to take a code library written for the Arduino shield USB host and separate it from the main Arduino libraries so that I can use the code in a microcontroller project without Arduino.
From looking at the code, there are not enough hard dependencies on the Arduino code base, but I come across some strange errors that are probably related to the differences between the Arduino build system and the LUFA build system . In particular, I get the following error in about 75% of the header files, a few dozen times each:
error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
Sometimes the error indicates different tokens in the error, but still the same error. I found many similar problems in different forums and in Stack Overflow, but the solution tends to be different every time.
To be clear, this code compiles a 100% penalty on the Arduino build system, but these errors occur when I try to build directly using WinAVR using the make LUFA template files. Looking through the code, I decided that I needed #define several values, such as -DARDUINO=102 (or at least some value> = 100, but the version of the Arduino IDE that I use is 1.0.2, so I decided that is good value to use).
So, I suppose I'm looking for someone familiar with the Arduino build system to help me figure out what I am missing. The complete code library can be found here , but in order to provide a simple example that demonstrates the problem without including the entire code library, here printhex.h :
#if !defined(__PRINTHEX_H__) #define __PRINTHEX_H__ #if defined(ARDUINO) && ARDUINO >=100 #include "Arduino.h" #else #include <WProgram.h> #endif template <class T> void PrintHex(T val) { T mask = (((T)1) << (((sizeof(T) << 1) - 1) << 2)); while (mask > 1) { if (val < mask) Serial.print("0"); mask >>= 4; } Serial.print((T)val, HEX); } template <class T> void PrintHex2(Print *prn, T val) { T mask = (((T)1) << (((sizeof(T) << 1) - 1) << 2)); while (mask > 1) { if (val < mask) prn->print("0"); mask >>= 4; } prn->print((T)val, HEX); } template <class T> void PrintBin(T val) { for (T mask = (((T)1) << (sizeof(T) << 3)-1); mask; mask>>=1) if (val & mask) Serial.print("1"); else Serial.print("0"); } #endif
I should note that I have Arduino.h copied to my inclusion path, and that if I include Arduino.h in my main .c file, it compiles fine, so there is no problem there. The inclusion of printhex.h , however, leads to the following:
In file included from MIDI.c:38: Lib/HostShield/printhex.h:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token Lib/HostShield/printhex.h:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token Lib/HostShield/printhex.h:56: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token make: *** [MIDI.o] Error 1
Lines 26, 41, and 56 are three examples of the following:
template <class T>
I'm at a dead end. How can I solve this problem?