IDE - Dependent Failure to Compile

Hi All.

The code below compiles just fine in the Arduino IDE. But, it fails in Eclipse / Sloeber. The error messages from Eclipse are shown. I’m thinking that Arduino is doing “something” behind the scenes to help me out. But, Eclipse doesn’t do that “something” for me and I need to do it myself.

Also, the complaints seem to be originating from an automatically-generated .cpp file. So, I’ve included that too.

Any help appreciated.

Thanks.

.ino file:

#include "Arduino.h"
enum myEnum {
  SYM0, SYM1, SYM2, SYM3, SYM4
};
myEnum returnEnum(myEnum);

void setup()
{
  Serial.begin(115200);
  delay(2000);
  Serial.println(returnEnum(SYM0));
}

void loop()
{
}

myEnum returnEnum(myEnum x) {
  return x;
}

Eclipse / Sloeber Error Messages:

08:30:14 **** Build of configuration Release for project yyy ****
"C:\\sloeber\\arduinoPlugin\\tools\\make\\make" all 
'Building file: ..\.ino.cpp'
'Starting C++ compile'
"C:\sloeber\/arduinoPlugin/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   -I"C:\sloeber\arduinoPlugin\packages\arduino\hardware\avr\1.6.20\cores\arduino" -I"C:\sloeber\arduinoPlugin\packages\arduino\hardware\avr\1.6.20\variants\standard" -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.o" -D__IN_ECLIPSE__=1 -x c++ "..\.ino.cpp"  -o  ".ino.cpp.o"
..\.ino.cpp:11:1: error: 'myEnum' does not name a type
 myEnum returnEnum(myEnum x) ;
 ^
subdir.mk:24: recipe for target '.ino.cpp.o' failed
make: *** [.ino.cpp.o] Error 1

08:30:14 Build Finished (took 632ms)

Automatically-generated .cpp file:

#ifdef __IN_ECLIPSE__
//This is a automatic generated file
//Please do not modify this file
//If you touch this file your change will be overwritten during the next build
//This file has been generated on 2017-11-17 08:30:07

#include "Arduino.h"
#include "Arduino.h"
void setup() ;
void loop() ;
myEnum returnEnum(myEnum x) ;

#include "yyy.ino"

#endif

Delta_G:
You need to write your own function declaration. The Arduino stuff is trying to generate it for you but it's putting it up before the enum definition.

Isn't that a proper function declaration I have right below the enum definition?

enum myEnum {
  SYM0, SYM1, SYM2, SYM3, SYM4
};
myEnum returnEnum(myEnum);

I thought if I provided that prototype it would stop the Arduino stuff from doing so. Seems to work in the Arduino IDE.

OK, that worked. Thankfully, clicking the File --> New --> Arduino Sketch sequence provides a “Default cpp File” option. So, it still does the work of pulling in the correct board-dependent stuff. I could never configure all the toolchain and compiler options stuff myself.

Anyway, for this simple-minded example I didn’t even need .h file.

.cpp file:

#include "Arduino.h"
enum animal {dog, cat, pig, horse, cow};
animal returnAnimal(animal);

void setup() {
 Serial.begin(115200);
 delay(2000);
 Serial.println(returnAnimal(dog));
}

void loop() {
}

animal returnAnimal(animal x) {
 return x;
}

So, I owe you $1. Send me your Venmo ID ;D

have you looked at http://platformio.org/?

I've been using the ATOM plugin, which is a very rich dev tool...

BulldogLowell:
have you looked at http://platformio.org/?

I've been using the ATOM plugin, which is a very rich dev tool...

I did give it a quick look. In my opinion (and this may be incorrect / unfair), it involves too much dorking around: install python, install Atom, install Platform IO.

Worse still, it looks like you need to mess around with a Command Line Interface and manually edit .ini files. This is 2017, not 1977.

Like I said, there’s a good chance I’m off-base here. But, that was my impression after poking around for 30 minutes.

gfvalvo:
Worse still, it looks like you need to mess around with a Command Line Interface and manually edit .ini files. This is 2017, not 1977.

No, it is a very active platform that has been improved a shit ton since that demo.

  • install ATOM (which is rapidly becoming one of the best development environments due to all of its support, plus nice GitHub integration)
  • install the Packages

that's it. I'm on a mac so it may be a whole bunch easier than if you are using a Windows machine. :confused:

install whatever other packages you want (there are thousands) that help you the most.

Seriously worth the 5 mins to get it running.

“Better” is the enemy of “Good Enough”. Arduino IDE is not quite good enough, so I’m moving on to Eclipse. Here I’ll squat until it’s not good enough, which will probably be never.

Once I’m comfortable writing and building code in this environment, I will attempt to tackle version control.

gfvalvo:
Arduino IDE is not quite good enough...

how very polite of you. :wink:

from where I live it is about ten light years away from good enough, once you get past blinking an LED!!

Perhaps now with the re-unification of Arduino, they will set about choosing wether to buy, develop or invest in (open-source) an IDE for the 20th century.