This error is occurring because there are two files that are defining LITTLE_ENDIAN. This is why it says its being "redefined"
These two files are "endian.h" and "samd21g18a.h"
I'm using platformio with VSCode, not the Arduino IDE, so I can only talk about where the files are on my computer:
The "endian.h" file is located in the toolchain-gccarm folder. That is the default for the arm compiler that I'm using.
- This file sets LITTLE_ENDIAN to 1234
The "samd21g18a.h" file is located in the framework arduinosam folder. It is specific to the board that I am using.
- This file sets LITTLE_ENDIAN to 1
I noticed that if I compile it as is (with the warnings) and print the value of LITTLE_ENDIAN in my program, I can see it is set prints as '1234'
- This means that it's getting its LITTLE_ENDIAN value from the compiler, not the one for the chip.
Like you've already noted, this doesn't seem to matter, either way has the same result.
So if it doesnt matter, lets fix the warning. This is how I did it:
I fixed the warning message by going to the files where '#define LITTLE_ENDIAN' is defined and I put a header guard around it
EXAMPLE:
in the "endian.h" file it now says:
#if __BSD_VISIBLE
[color=blue]#ifndef LITTLE_ENDIAN
[/color]#define LITTLE_ENDIAN _LITTLE_ENDIAN
[color=blue]#endif
[/color]#define BIG_ENDIAN _BIG_ENDIAN
#define PDP_ENDIAN _PDP_ENDIAN
#define BYTE_ORDER _BYTE_ORDER
#endif
and in the "samd21g18.h" it now says:
/*
* \brief Configuration of the Cortex-M0+ Processor and Core Peripherals
*/
[color=blue]#ifndef LITTLE_ENDIAN
[/color]#define LITTLE_ENDIAN 1
[color=blue]#endif
[/color]#define __CM0PLUS_REV 1 /*!< Core revision r0p1 */
#define __MPU_PRESENT 0 /*!< MPU present or not */
#define __NVIC_PRIO_BITS 2 /*!< Number of bits used for Priority Levels */
#define __VTOR_PRESENT 1 /*!< VTOR present or not */
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
changes are in blue.
After compiling the project, the value of LITTLE_ENDIAN is 1, because it takes on the value assigned by the chip, not the compiler, but it makes no difference to the way it operates
Further research of this particular chip (SAMD21G18A) shows that the endian-ness is set by the chip, so changing this value shouldnt make a difference at all.