I am getting this problem while connecting RFID-RC522 with ESP32? can anyone tell what error is this?

c:\Users\steph\OneDrive\Documents\Arduino\libraries\MFRC522\src\MFRC522Extended.cpp: In member function 'MFRC522::StatusCode MFRC522Extended::TCL_Transceive(TagInfo*, byte*, byte, byte*, byte*)':
c:\Users\steph\OneDrive\Documents\Arduino\libraries\MFRC522\src\MFRC522Extended.cpp:824:34: error: ordered comparison of pointer with integer zero ('byte*' {aka 'unsigned char*'} and 'int')
824 | if (backData && (backLen > 0)) {
| ~~~~~~^
c:\Users\steph\OneDrive\Documents\Arduino\libraries\MFRC522\src\MFRC522Extended.cpp:847:42: error: ordered comparison of pointer with integer zero ('byte*' {aka 'unsigned char*'} and 'int')
847 | if (backData && (backLen > 0)) {
| ~~~~~~^

exit status 1

Compilation error: exit status 1

Welcome to the forum

Your topic has been moved to the Programming category of the forum

Please post the full sketch that produced the errors and details of the project such as which Arduino board you are using

Perhaps it is telling you that you are trying to compare the pointer to a character, when you should be comparing the variable the pointer points to.

the code is working with Arduino uno. but when i use esp32 it is not working.

As previously requested, please post the full sketch, using code tags when you do

Unlike the Uno boards file, the ESP32 boards file treats warnings as errors. Instructions for fixing that behaviour can be found here:

What you say about warnings being treated as errors in the ESP32 environment is true, but the errors posted so far are not warnings

That turns out not to be the case.

With --warnings all set and compiling for the Uno R3, the following is observed:

cli compile -b arduino:avr:uno --warnings all --output-dir /home/wayneh/tmp --no-color (in directory: /home/me/Documents/sketchbook/Uno_R3/RC522_test)
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp: In member function 'MFRC522::StatusCode MFRC522Extended::TCL_Transceive(MFRC522Extended::TagInfo*, byte*, byte, byte*, byte*)':
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp:824:29: warning: ordered comparison of pointer with integer zero [-Wextra]
  if (backData && (backLen > 0)) {
                             ^
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp:847:30: warning: ordered comparison of pointer with integer zero [-Wextra]
  if (backData && (backLen > 0)) {
                             ^

Sketch uses 20694 bytes (64%) of program storage space. Maximum is 32256 bytes.
Global variables use 618 bytes (30%) of dynamic memory, leaving 1430 bytes for local variables. Maximum is 2048 bytes.
Used library         Version Path
MFRC522              1.4.3   /home/me/Documents/sketchbook/libraries/MFRC522
SPI                  1.0     /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/libraries/SPI
Adafruit SSD1306     2.5.7   /home/me/Documents/sketchbook/libraries/Adafruit_SSD1306
Adafruit GFX Library 1.11.9  /home/me/Documents/sketchbook/libraries/Adafruit_GFX
Adafruit BusIO       1.14.5  /home/me/Documents/sketchbook/libraries/Adafruit_BusIO
Wire                 1.0     /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3/libraries/Wire
Used platform Version Path
arduino:avr   1.8.3   /home/me/.arduino15/packages/arduino/hardware/avr/1.8.3
Compilation finished successfully.

Please note that when compiling for the Uno R3, the ordered comparison of pointer with integer zero is a warning.

When compiling the same code on the ESP32 with the unmodified platform.txt file specifying -Werror, the following is observed:

cli compile -b esp32:esp32:firebeetle32 --warnings all --output-dir /home/me/tmp --no-color (in directory: /home/me/Documents/sketchbook/ESP32/RC522_test)
WARNING: library MFRC522 claims to run on avr, STM32F1, teensy, esp8266, samd architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp: In member function 'MFRC522::StatusCode MFRC522Extended::TCL_Transceive(MFRC522Extended::TagInfo*, byte*, byte, byte*, byte*)':
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp:824:29: error: ordered comparison of pointer with integer zero [-Werror=extra]
  if (backData && (backLen > 0)) {
                             ^
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp:847:30: error: ordered comparison of pointer with integer zero [-Werror=extra]
   if (backData && (backLen > 0)) {
                              ^
cc1plus: all warnings being treated as errors
Used library         Version Path
MFRC522              1.4.3   /home/me/Documents/sketchbook/libraries/MFRC522
SPI                  2.0.0   /home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/libraries/SPI
Adafruit SSD1306     2.5.7   /home/me/Documents/sketchbook/libraries/Adafruit_SSD1306
Adafruit GFX Library 1.11.9  /home/me/Documents/sketchbook/libraries/Adafruit_GFX
Adafruit BusIO       1.14.5  /home/me/Documents/sketchbook/libraries/Adafruit_BusIO
Wire                 2.0.0   /home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/libraries/Wire
Used platform Version Path
esp32:esp32   2.0.14  /home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14
Error during build: exit status 1
Compilation failed.

You can plainly see that with the use of -Werror the ordered comparison of pointer with integer zero is now being reported as an error rather than a warning. This is expected behaviour from the gcc documentation:

-Werror

    Make all warnings into errors.

When -Werror is removed from the ESP32 platform.txt file, as recommended in the link I included previously, ordered comparison of pointer with integer zero is reported as a warning (as it was for the Uno R3), and the code compiles successfully,.

cli compile -b esp32:esp32:firebeetle32 --warnings all --output-dir /home/me/tmp --no-color (in directory: /home/me/Documents/sketchbook/ESP32/RC522_test)
WARNING: library MFRC522 claims to run on avr, STM32F1, teensy, esp8266, samd architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s).
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp: In member function 'MFRC522::StatusCode MFRC522Extended::TCL_Transceive(MFRC522Extended::TagInfo*, byte*, byte, byte*, byte*)':
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp:824:29: warning: ordered comparison of pointer with integer zero [-Wextra]
  if (backData && (backLen > 0)) {
                             ^
/home/me/Documents/sketchbook/libraries/MFRC522/src/MFRC522Extended.cpp:847:30: warning: ordered comparison of pointer with integer zero [-Wextra]
   if (backData && (backLen > 0)) {
                              ^
/home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/cores/esp32/esp32-hal-uart.c: In function 'uartSetPins':
/home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/cores/esp32/esp32-hal-uart.c:153:9: warning: 'return' with no value, in function returning non-void
         return;
         ^~~~~~
/home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/cores/esp32/esp32-hal-uart.c:149:6: note: declared here
 bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
      ^~~~~~~~~~~
Sketch uses 297601 bytes (22%) of program storage space. Maximum is 1310720 bytes.
Global variables use 21864 bytes (6%) of dynamic memory, leaving 305816 bytes for local variables. Maximum is 327680 bytes.
Used library         Version Path
MFRC522              1.4.3   /home/me/Documents/sketchbook/libraries/MFRC522
SPI                  2.0.0   /home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/libraries/SPI
Adafruit SSD1306     2.5.7   /home/me/Documents/sketchbook/libraries/Adafruit_SSD1306
Adafruit GFX Library 1.11.9  /home/me/Documents/sketchbook/libraries/Adafruit_GFX
Adafruit BusIO       1.14.5  /home/me/Documents/sketchbook/libraries/Adafruit_BusIO
Wire                 2.0.0   /home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14/libraries/Wire
Used platform Version Path
esp32:esp32   2.0.14  /home/me/.arduino15/packages/esp32/hardware/esp32/2.0.14
Compilation finished successfully.

To sum up: editing the platform.txt file, as recommended in the link given in my original message, allows the (admittedly awful) library code to successfully compile on the ESP32. QED

I've the same problem but I cannot find the right platform.txt file. I'm using Debian and I've found the file under /home/*myuser*/.arduino15/packages/esp32/hardware/esp32/3.0.1 but cannot find -Werror anywhere.

What I'm doing wrong?

I'm working with esp32 version 3.0.1 and have the same problem.
In platform.txt it looks like this.

# Arduino Compile Warning Levels
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra

As you can see the -Werror got fixed, but the problem with the other library still exists.

c:\Users\Jonas\Documents\Arduino\libraries\MFRC522\src\MFRC522Extended.cpp: In member function 'MFRC522::StatusCode MFRC522Extended::TCL_Transceive(TagInfo*, byte*, byte, byte*, byte*)':
c:\Users\Jonas\Documents\Arduino\libraries\MFRC522\src\MFRC522Extended.cpp:824:34: error: ordered comparison of pointer with integer zero ('byte*' {aka 'unsigned char*'} and 'int')
  824 |         if (backData && (backLen > 0)) {
      |                          ~~~~~~~~^~~
c:\Users\Jonas\Documents\Arduino\libraries\MFRC522\src\MFRC522Extended.cpp:847:42: error: ordered comparison of pointer with integer zero ('byte*' {aka 'unsigned char*'} and 'int')
  847 |                 if (backData && (backLen > 0)) {
      |                                  ~~~~~~~~^~~

exit status 1

Compilation error: exit status 1

Do you have any solutions?

as parameter backlen is is a pointer to byte

MFRC522::StatusCode MFRC522Extended::TCL_Transceive(TagInfo *tag, byte *sendData, byte sendLen, byte *backData, byte *backLen)

it looks as though the statement should be using the dereference operator *

if (backData && (*backLen > 0)) {

EDIT: looking at my ESP32 code I have used the Arduino_MFRC522v2 library

1 Like

Thanks, I edited the file and it works.

maybe worth marking post 11 as solution in case anyone else comes across the same problem

can i ask how you edit the file

That issue was handled on GitHub in the comments about the library. I remember you had to change some three lines concerning backlen, in a source file. It works, though it is now a while since I did it

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.