EEPROM.h:25:7: error: expected ‘=’


I am trying arduino-mk, my source code compiles, but avr-gcc accuses an arduino-library, EEPROM.h!

Probably some library specification is missing, but staring another hour on my code or search the internet another 10 times will not help, so I am asking here for help.

Platform: PC running Linux (Linux Mint 13)
Arduino installation from Ubuntu repository: arduino 1.0, arduino-core 1.0, arduino-mk 0.8-1

Environment (.bashrc content):

export ARDUINO_DIR=/usr/share/arduino
export ARDMK_DIR=/usr/share/arduino
export ARDMK_PATH=/usr/bin
export AVR_TOOLS_DIR=/usr[/font]


ARDUINO_DIR = /usr/share/arduino
BOARD_TAG    = atmega328
AVR_TOOLS_PATH	= /usr/bin
AVRDUDE_CONF	= /etc/avrdude.conf
include /usr/share/arduino/

‘make’ output:

/usr/bin/avr-gcc -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=100 -I. -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/standard -I/usr/share/arduino/libraries/EEPROM -g -Os -w -Wall -ffunction-sections -fdata-sections -std=gnu99 state.c -o build-cli/state.o
In file included from state.c:1:0:
/usr/share/arduino/libraries/EEPROM/EEPROM.h:25:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘EEPROMClass’
/usr/share/arduino/libraries/EEPROM/EEPROM.h:32:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘EEPROM’
make: *** [build-cli/state.o] Error 1

lines 25-32 in EEPROM.h:

class EEPROMClass
    uint8_t read(int);
    void write(int, uint8_t);

extern EEPROMClass EEPROM;

So does anyone have an idea what is missing?

So does anyone have an idea what is missing?

Context and detail?

My guess is that you are compiling a c file top-level so it is assuming EEPROM.h is C rather than C++, hence "class" isn't being recognised as a keyword.

This is correct. My top level file, having an .ino extension, is pure C syntax, as all programming examples I saw so far. The whole program consists of several .h and .c files, with includes.

So what do I have to do? Change program file contents? Makefile? Environment?

Thanks for the hint.

The Arduino environment does its sketch building in a very particular way - somewhat idiosyncratically perhaps, and you'll need to mimic that. Remember its all open-source, you can go and have a look at how its all done (its probably documented somewhere, I've had recourse to look myself).

Is there a reason you can't use the Arduino environment directly?

So what do I have to do?

Change all the c file extensions to cpp extension, or forget about using classes (EEPROM is a class) in your code.

The renaming trick did it. I was not aware that I know C++ ;-) Thanks a lot.

MarkT: Is there a reason you can't use the Arduino environment directly?

I did my first steps in Arduino programming a year ago and used the Arduino environment. Things I didn't like (or which were complicated to achieve, I don´t remember) were:

  • distribute code on several files and use #include
  • use emacs
  • use my preferences of directory structure and location

Now I am working on an enhanced version of my old program and headed directly to the command line environment.