0

I am currently trying to get EVAL-CN0391-ARDZ Shield for Arduino UNO to work on the Arduino DUE. However, when installing and implementing the necessary files from the product's respective webpage, I had one error upon building. The error is on the SPI_Write() and SPI_Read() functions.

The shortened error message reads: conflicting declaration of C function 'void SPI_Write(unsigned char, unsigned char*, unsigned char)'

The longer error message (just one part):

In file included from src\All CPP Files\AD7124.cpp:50:0:
include/Communication.h:62:6: error: conflicting declaration of C function 'void SPI_Read(unsigned     char, unsigned char*, unsigned char)'
  void SPI_Read(unsigned char slaveDeviceId, unsigned char* data, unsigned char bytesNumber);
  ^~~~~~~~
In file included from C:\Users\Anthony.limon\.platformio\packages\framework-arduino-    sam\system\libsam/chip.h:58:0,
                 from C:\Users\Anthony.limon\.platformio\packages\framework-arduino-    sam\cores\arduino/Arduino.h:42,
                 from C:\Users\Anthony.limon\.platformio\packages\framework-arduino-    sam\variants\arduino_due_x/variant.h:25,
                 from C:\Users\Anthony.limon\.platformio\packages\framework-arduino-    sam\libraries\SPI\src/SPI.h:15,
                 from include/Communication.h:40,
                 from src\All CPP Files\AD7124.cpp:50:
C:\Users\Anthony.limon\.platformio\packages\framework-arduino-sam\system\libsam/include/spi.h:92:17:     note: previous declaration 'uint32_t SPI_Read(Spi*)'
 extern uint32_t SPI_Read( Spi* spi ) ;
             ^~~~~~~~
*** [.pio\build\due\src\All CPP Files\CN0391.cpp.o] Error 1
*** [.pio\build\due\src\All CPP Files\AD7124.cpp.o] Error 1
*** [.pio\build\due\src\All CPP Files\Communication.cpp.o] Error 1
*** [.pio\build\due\src\main.cpp.o] Error 1

I am new to these types of problems and am not very experienced. That being said, I haven't tried much but try to follow along other people having similar issues on the web. This method has not been very helpful as I am not sure to what even look up besides the error message which has not been very helpful.

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • `conflicting declaration of C function` C does not allow function overloads. C++ does. It seems to me you are using a C library where you should be using a C++ library. – Captain Giraffe Apr 13 '23 at 14:10
  • 1
    Does this header have `#ifdef __cplusplus extern "C" { #endif` and `#ifdef __cplusplus } #endif` guards for the **C** functionality it exposes? – Andrew Henle Apr 13 '23 at 14:12
  • It would appear that the brilliant people who make these pre-made, high-quality libs have created two files spi.h at different locations, with different function types inside. Why is there a header file inside the folder `framework-arduino-sam\libraries\SPI\src` called spi.h? Why is there a header inside a folder named `src` when they have otherwise made it a habit to place headers inside a folder named `include`... these are all good, valid questions. – Lundin Apr 13 '23 at 14:14
  • @AndrewHenle C or C++, there shouldn't be two files named spi.h in the same project. That's the problem here. – Lundin Apr 13 '23 at 14:17
  • It looks like you have two separate independent libraries with conflicting declarations. – n. m. could be an AI Apr 13 '23 at 14:18
  • Just change SPI_read/write in the example to whatever (and all references) or remove extern "C" { and corresponding ifdefs – KIIV Apr 14 '23 at 10:32

0 Answers0