Warning in arduino , ignore them or how to correct them

  1. I am using Arduino 1.8.1 & made a code in it. Board it Atemga2560 R3

  2. I had made multiple .ino files in it & multiple headers in it. It has total 16 .ino files & 18 header files, where each .ino has its own header file plus two additional & from setup.ino rest all .ino file functions are called.

  3. I know arduino is not meant for that, but i have experience in using multiple c files in other IDE. In this project I had to interface fingerprint sensor, so instead of writing new library I had used Adafruit library for that purpose, which is main reason for selection of arduino at first place, otherwise i have to write complete new library on a new microcontroller.

  4. Code built was 674 bytes (8%) of dynamic memory & 22428 bytes (8%) of program storage space.

  5. Upon build below is verbose generated. It has no error, but warning in two files: One is fingerprint library & other is eeprom library of internal arduino.
    Fingerprint warning does not seem to be of much error & can be ignored but i dont understand these eeprom error.
    Problem is in arduino on clicking error, it wont open that file.
    Should i ignore these warnings? In general i prefer code with 0 error 0 warnings.

  6. Also any GOOD reference library codes for fingerprint module to be written in c for any microcontroller.

"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\abc\Documents\Arduino\libraries\TimerOne-master" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\EEPROM\src" "C:\Program Files\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp" -o "C:\Users\abc\AppData\Local\Temp\arduino_build_868020\libraries\LiquidCrystal\LiquidCrystal.cpp.o"
Compiling library "Adafruit-Fingerprint-Sensor-Library-master"
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\abc\Documents\Arduino\libraries\TimerOne-master" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\EEPROM\src" "C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp" -o "C:\Users\abc\AppData\Local\Temp\arduino_build_868020\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp.o"
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp: In member function 'boolean Adafruit_Fingerprint::verifyPassword()':
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:58:36: warning: narrowing conversion of '(((Adafruit_Fingerprint*)this)->Adafruit_Fingerprint::thePassword >> 24)' from 'uint32_t {aka long unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
                       (thePassword >> 24), (thePassword >> 16),
 
                                    ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:58:57: warning: narrowing conversion of '(((Adafruit_Fingerprint*)this)->Adafruit_Fingerprint::thePassword >> 16)' from 'uint32_t {aka long unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
                       (thePassword >> 24), (thePassword >> 16),
 
                                                         ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:59:36: warning: narrowing conversion of '(((Adafruit_Fingerprint*)this)->Adafruit_Fingerprint::thePassword >> 8)' from 'uint32_t {aka long unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
                       (thePassword >> 8), thePassword};
 
                                    ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:59:54: warning: narrowing conversion of '((Adafruit_Fingerprint*)this)->Adafruit_Fingerprint::thePassword' from 'uint32_t {aka long unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
                       (thePassword >> 8), thePassword};
 
                                                      ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp: In member function 'uint8_t Adafruit_Fingerprint::storeModel(uint16_t)':
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:109:51: warning: narrowing conversion of '(id >> 8)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
   uint8_t packet[] = {FINGERPRINT_STORE, 0x01, id >> 8, id & 0xFF};
 
                                                   ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:109:60: warning: narrowing conversion of '(id & 255u)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
   uint8_t packet[] = {FINGERPRINT_STORE, 0x01, id >> 8, id & 0xFF};
 
                                                            ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp: In member function 'uint8_t Adafruit_Fingerprint::loadModel(uint16_t)':
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:120:52: warning: narrowing conversion of '(id >> 8)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
     uint8_t packet[] = {FINGERPRINT_LOAD, 0x01, id >> 8, id & 0xFF};
 
                                                    ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:120:61: warning: narrowing conversion of '(id & 255u)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
     uint8_t packet[] = {FINGERPRINT_LOAD, 0x01, id >> 8, id & 0xFF};
 
                                                             ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp: In member function 'uint8_t Adafruit_Fingerprint::deleteModel(uint16_t)':
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:141:48: warning: narrowing conversion of '(id >> 8)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
     uint8_t packet[] = {FINGERPRINT_DELETE, id >> 8, id & 0xFF, 0x00, 0x01};
 
                                                ^
 
C:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master\Adafruit_Fingerprint.cpp:141:57: warning: narrowing conversion of '(id & 255u)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
 
     uint8_t packet[] = {FINGERPRINT_DELETE, id >> 8, id & 0xFF, 0x00, 0x01};
 
                                                         ^

Eeprom file error

[code]"C:\Program Files\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\abc\AppData\Local\Temp\arduino_build_868020\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\mega" "-IC:\Users\abc\Documents\Arduino\libraries\TimerOne-master" "-IC:\Program Files\Arduino\libraries\LiquidCrystal\src" "-IC:\Program Files\Arduino\libraries\Adafruit-Fingerprint-Sensor-Library-master" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src" "-IC:\Program Files\Arduino\hardware\arduino\avr\libraries\EEPROM\src" "C:\Users\abc\AppData\Local\Temp\arduino_build_868020\sketch\setup.ino.cpp" -o "C:\Users\abc\AppData\Local\Temp\arduino_build_868020\sketch\setup.ino.cpp.o"
In file included from C:\Users\abc\AppData\Local\Temp\arduino_build_868020\sketch\eeprom.h:12:0,
 
                 from C:\Users\abc\Desktop\V19_minor\setup\eeprom.ino:5:
 
C:\Program Files\Arduino\hardware\arduino\avr\libraries\EEPROM\src/EEPROM.h:43:30: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
 
     operator const uint8_t() const       { return **this; }
 
                              ^
 
C:\Program Files\Arduino\hardware\arduino\avr\libraries\EEPROM\src/EEPROM.h:92:26: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
 
     operator const int() const          { return index; }
 
                          ^

[/code]

Vindhyachal_Takniki:
3. I know arduino is not meant for that

Why not? Although the typical Arduino beginner won't use it in this way you are welcome to do as you please.

Vindhyachal_Takniki:
It has no error, but warning in two files: One is fingerprint library & other is eeprom library of internal arduino.

Isn't that annoying? I write my code so there are no warnings but then I get stuck with a bunch from other people's code. The esp8266 core is the worst for that!

Vindhyachal_Takniki:
Should i ignore these warnings? In general i prefer code with 0 error 0 warnings.

The problem with fixing warnings in libraries is that you need to redo it any time you update to a new version. The best thing is to fix the warnings and then submit a pull request to the relevant repository. That solves the problem for everyone and also ends up being less work for you in the end. We have been promised a fix for the warnings in the EEPROM library for >1.5 years now:

At this point I think it's safe to assume that's not going to happen and someone needs to step in and submit a pull request to fix this. You might be able to extract the fixes from the fork at the link in that issue report, otherwise they should be easy enough to fix.

It's sad because I really like the new EEPROM library but it's one of the last libraries bundled with the Arduino IDE to have warnings. It used to be that most of the Arduino libraries had warnings but they're way better about that now.

Vindhyachal_Takniki:
Problem is in arduino on clicking error, it wont open that file.

Yeah, the Arduino IDE doesn't have that useful feature but you can see the path to the file and line number right in the error so it's easy enough to find.

The syntax parser for the post-1.8 IDE seems to be a little tighter than before. If the compiler can generate and load the sketch, chances are the code's ok. That said, it would be nice to get rid of those warnings.You can fix the error, especially if it's in your own code. If it's in a library, I'll let the author of the library do the fix, mainly because they know it far better than I do.

It's hard to pinpoint the problems, but some you can guess. For example:

  • uint8_t packet = {FINGERPRINT_LOAD, 0x01, id >> 8, id & 0xFF};*

has two warnings, both associated with expressions involving id. My guess is that id is an int and the code is stripping away 8 bits so it can be assigned into an unsigned byte array. The expression uses an implicit cast. What happens if you change the expressions to:

  • uint8_t packet = {FINGERPRINT_LOAD, 0x01, (uint8_t) id >> 8, (uint8_t) id & 0xFF};*