Compilation error - only from the IDE

Hi chaps,
After several months, I finally managed to resurrect my GSM MKR 1400 using a hack to bypass the USB connection (not working, got burnt while using the MKR) using the FTDI232 board.

Anyway. Recompiled a sketch that was working and I got this error from the IDE (v. 1.8.9): /home/.../.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined
#define LITTLE_ENDIAN

LITTLE_ENDIAN is defined in /home/.../.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/machine/endian.h:17:0:
#define LITTLE_ENDIAN _LITTLE_ENDIAN

So the compilation stops.

So I tried with an example - sendSMS. I get the same error.

However, if I use the web IDE, I get no error.

The library I'm using is GSM 1.0.6 abd MKRGSM 1.4.2

What has happened in the past months? Anybody experiencing the same problem?

Cheers,
DMax66

Update: the messages are just warning. The compilation succeeds and the code works.

I didn't notice the problem before as I had the warnings turned off.

I think this closes the question, even if I'd love to get no warnings from the compiler.

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.

I'm having exactly the same issue.

I had the same problem with the MKR1500. The compilation directive solved it too. I would get over a dozen errors like:

AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: “LITTLE_ENDIAN” redefined

but it would compile ok. Just scary looking but now it’s solved with this fix. They should add this to the next release. :wink: