Greetings -
As I work on a C++ project, this error has become the single most frequent one, and I don't know what it is trying to tell me or how to identify the cause. Pretty sure that it is a C++ error rather than a simple C syntax error (eg, badly formed if() statement, for example). So, here is the header file where the IDE points to the errors (two which likely have the same cause):
#ifndef ORE_SERIAL_H #define ORE_SERIAL_H #include <avr/io.h> #include <stdint.h> #include "ArduinoConstants.h" #define PRINT_CR 1 #define PRINT_LF 2 #define PRINT_CRLF 3 #define PRINT_EOL PRINT_CRLF //base designators for print() functions #define BIN 2 //binary #define OCT 8 //octal #define DEC 10 //decimal #define HEX 16 //hexadecimal #define BITS8 (1<<UCSZ01)|(1<<UCSZ00) #define STOP1 0 #define PARITYN 0 #define SERIAL_8N1 BITS8|PARITYN|STOP1 // (the default) class ORE_Serial { private: uint8_t RxIdx; char * RxPtr; char RxBuf[64]; char NumBuf[34]; //for 32bit ascii binary string plus null terminator uint16_t printEOL ( ); public: void begin(uint16_t,uint8_t); void end(); //character uint16_t print( char ); uint16_t println( char ); //string uint16_t print( char * ); uint16_t println( char * ); //8-bit number //16-bit number uint16_t print( int16_t , uint8_t ); uint16_t println( int16_t , uint8_t ); uint16_t print( uint16_t , uint8_t ); uint16_t println( uint16_t , uint8_t ); uint16_t print( int16_t ); uint16_t println( int16_t ); uint16_t print( uint16_t ); uint16_t println( uint16_t ); //32-bit number uint16_t print( int32_t , uint8_t ); uint16_t println( int32_t, uint8_t ); uint16_t print( int32_t ); uint16_t println( int32_t); uint16_t print( uint32_t , uint8_t ); uint16_t println( uint32_t, uint8_t ); uint16_t print( uint32_t ); uint16_t println( uint32_t); //double (floating point) uint16_t print( double , uint8_t ); uint16_t println( double , uint8_t ); uint16_t print( double ); uint16_t println( double ); }; #endif //ORE_SERIAL_H
There are other defines that have been commented out, attempting to remove them as possible error sources. The errors point to the line
class ORE_Serial {
The Error List shows:
Severity
Code
Description
Project
File
Line
Error
unknown type name 'class'
ORE_Test
C:\Users\Jim\Dropbox\FloodWatcher\Code\ORE_Test\ORE_Test\ArduinoCompatibility\ORE_Serial.h
90
Error
expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
ORE_Test
C:\Users\Jim\Dropbox\FloodWatcher\Code\ORE_Test\ORE_Test\ArduinoCompatibility\ORE_Serial.h
90
The Output shows:
------ Build started: Project: ORE_Test, Configuration: Debug AVR ------
Build started.
Project "ORE_Test.cppproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\Jim\Dropbox\FloodWatcher\Code\ORE_Test\ORE_Test\ORE_Test.cppproj" (target "Build" depends on it):
Task "RunCompilerTask"
Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all
Building file: ../ArduinoCompatibility/ORE_Serial.cpp
Invoking: AVR8/GNU C Compiler : 4.9.2
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega328p" -c -MD -MP -MF "ORE_Serial.d" -MT"ORE_Serial.d" -MT"ORE_Serial.o" -o "ORE_Serial.o" "../ArduinoCompatibility/ORE_Serial.cpp"
Finished building: ../ArduinoCompatibility/ORE_Serial.cpp
Building file: .././main.cpp
Invoking: AVR8/GNU C Compiler : 4.9.2
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega328p" -c -MD -MP -MF "main.d" -MT"main.d" -MT"main.o" -o "main.o" ".././main.cpp"
Finished building: .././main.cpp
Building file: ../ArduinoCompatibility/ORE_Digital.c
Invoking: AVR8/GNU C Compiler : 4.9.2
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega328p" -c -std=gnu99 -MD -MP -MF "ORE_Digital.d" -MT"ORE_Digital.d" -MT"ORE_Digital.o" -o "ORE_Digital.o" "../ArduinoCompatibility/ORE_Digital.c"
In file included from ../ArduinoCompatibility/ArduinoCompatibility.h:27:0,
from ../ArduinoCompatibility/ORE_Digital.c:32:
C:\Users\Jim\Dropbox\FloodWatcher\Code\ORE_Test\ORE_Test\ArduinoCompatibility\ORE_Serial.h(90,1): error: unknown type name 'class'
class ORE_Serial {
^
C:\Users\Jim\Dropbox\FloodWatcher\Code\ORE_Test\ORE_Test\ArduinoCompatibility\ORE_Serial.h(90,18): error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
class ORE_Serial {
^
make: *** [ORE_Digital.o] Error 1
Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "ORE_Test.cppproj" -- FAILED.
Done building project "ORE_Test.cppproj" -- FAILED.
Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
I HAD been able to build this project, successfully, until removing some tests for the presence or absence of a specific define that were sprinkled through all of the header files.
At this point, I have no clue about where to look. Suggestions, hints, references to previous threads where someone already gave me the answer to this :=) are all welcome.
Many thanks
jim