Errors compiling header files


#1

To tech support, thank you for the support!

I hope to using the makeblock robotics in the classroom, I am a high school teacher here in Ontario, Canada

I placed the makeblock folder (and src and other subfolders) inside the libraries folder in the Arduino installation folder.

When I try to compile the program with the #include “MeMegaPi.h” header file, I received the following error messages:

Arduino: 1.6.12 (Windows 7), Board: “Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)”

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:73:0: warning: “SLOT_1” redefined

** #define SLOT_1 1**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MePort.h:108:0: note: this is the location of the previous definition

** #define SLOT_1 SLOT1**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:74:0: warning: “SLOT_2” redefined

** #define SLOT_2 2**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MePort.h:109:0: note: this is the location of the previous definition

** #define SLOT_2 SLOT2**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:75:0: warning: “SLOT_3” redefined

** #define SLOT_3 3**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MePort.h:110:0: note: this is the location of the previous definition

** #define SLOT_3 SLOT3**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:76:0: warning: “SLOT_4” redefined

** #define SLOT_4 4**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MePort.h:111:0: note: this is the location of the previous definition

** #define SLOT_4 SLOT4**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:77:0: warning: “SLOT1” redefined

** #define SLOT1 SLOT_1**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MePort.h:104:0: note: this is the location of the previous definition

** #define SLOT1 (1)**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:78:0: warning: “SLOT2” redefined

** #define SLOT2 SLOT_2**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MePort.h:105:0: note: this is the location of the previous definition

** #define SLOT2 (2)**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:65:0,

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**

C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeStepperOnBoard.h:79:0: warning: “SLOT3” redefined

** #define SLOT3 SLOT_3**

** ^**

In file included from C:\Program Files (x86)\Arduino\libraries\makeblock\src/Me7SegmentDisplay.h:70:0,

** from C:\Program Files (x86)\Arduino\libraries\makeblock\src/MeMegaPi.h:42,**

** from C:\Users\SPURO~1.SOU\AppData\Local\Temp\untitled961158797.tmp\sketch_nov21a\sketch_nov21a.ino:1:**


#2

Can you post your sketch?

Usually this sort of error occurs when a variable is defined using #define. If you are manually defining SLOT1 or SLOT3 in your sketch you will get this type of error. One workaround, if you must define your values manually is to use an #undef in an #ifdef code block:

#ifdef SLOT1
    #undef SLOT1
    #define SLOT1 new_value
#endif

Another approach would be to use:

#ifndef SLOT1
    #define SLOT1
#endif

The latter approach is usually preferred and acts as a safety belt to prevent the use of undefined values. The former merely allows you to redefine the value yourself.

cc: @tec_support


#3