I build a Arduino code and got this warning, what to do remove these or left them like this? Using arduino 1.8.12
For speed optimization in platform.txt I have replace all the -Os with -O3.
I build a Arduino code and got this warning, what to do remove these or left them like this? Using arduino 1.8.12
For speed optimization in platform.txt I have replace all the -Os with -O3.
Post text, not pictures of text.
Post all the text.
Post the code that produced the text.
"... may be uninitialized ..." seems fairly obvious to me but I cannot help without code. Bye!
Where did you get the SD library, it does not appear to be the default location for the library supplied with the IDE.
You will likely need to modify the library, that particular warning is often caused by declaring a variable without initializing it, then having its value set within one or more conditional statements. The compiler sees that the conditional statement(s) could possibly never be met, and therefore the variable never gets set to a known value, but the programmer knows (or assumes) that the conditions will always result in the variable being given a value.
With a well-tested library, I would not worry about that type warning.
Here is simple code, which thow this warning.
Arduino Mega 2560, arduino 1.8.12 & For speed optimization in platform.txt I have replace all the -Os with -O3.
test.ino (803 Bytes)
Please do this:
If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link that will allow you to make the attachment.
I'm getting the same error with IDE version 1.8.13, but only when the platform.txt file is edited to change the compile option to -O3, does not show up with the default -Os, -01, or -02. The error is not occurring in the actual compile, but in the linker.
Compiling core...
Using precompiled core: /tmp/arduino_cache_869148/core/core_arduino_avr_uno_9175a212b9076fd4b27f4df39efa017e.a
Linking everything together...
/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -Wall -Wextra -O3 -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o /tmp/arduino_build_879023/test.ino.elf /tmp/arduino_build_879023/sketch/test.ino.cpp.o /tmp/arduino_build_879023/libraries/SPI/SPI.cpp.o /tmp/arduino_build_879023/libraries/SD/File.cpp.o /tmp/arduino_build_879023/libraries/SD/SD.cpp.o /tmp/arduino_build_879023/libraries/SD/utility/Sd2Card.cpp.o /tmp/arduino_build_879023/libraries/SD/utility/SdFile.cpp.o /tmp/arduino_build_879023/libraries/SD/utility/SdVolume.cpp.o /tmp/arduino_build_879023/../arduino_cache_869148/core/core_arduino_avr_uno_9175a212b9076fd4b27f4df39efa017e.a -L/tmp/arduino_build_879023 -lm
/home/pi/.arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/main.cpp: In function 'main':
/home/pi/Downloads/arduino-1.8.13/libraries/SD/src/utility/SdFat.h:151:7: warning: 'MEM[(struct SdFile *)&d1].firstCluster_' may be used uninitialized in this function [-Wmaybe-uninitialized]
class SdFile : public Print {
^
/home/pi/Downloads/arduino-1.8.13/libraries/SD/src/SD.cpp:375:12: note: 'MEM[(struct SdFile *)&d1].firstCluster_' was declared here
SdFile d1;
^
/home/pi/Downloads/arduino-1.8.13/libraries/SD/src/utility/SdFat.h:151:7: warning: 'MEM[(struct SdFile *)&d1].fileSize_' may be used uninitialized in this function [-Wmaybe-uninitialized]
class SdFile : public Print {
^
/home/pi/Downloads/arduino-1.8.13/libraries/SD/src/SD.cpp:375:12: note: 'MEM[(struct SdFile *)&d1].fileSize_' was declared here
SdFile d1;
^
/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_879023/test.ino.elf /tmp/arduino_build_879023/test.ino.eep
/home/pi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_879023/test.ino.elf /tmp/arduino_build_879023/test.ino.hex
Using library SPI at version 1.0 in folder: /home/pi/.arduino15/packages/arduino/hardware/avr/1.8.3/libraries/SPI
Using library SD at version 1.2.4 in folder: /home/pi/Downloads/arduino-1.8.13/libraries/SD
yes this is error, what the solution for it? Have to debug t -O3 only for speed optimization, any other solution?
You need to understand the difference between warnings and errors. A warning is the compiler telling you there is something in the code that could possibly cause a problem but doesn't cause the compilation to fail. An error is a problem with the code that causes compilation to fail. In this case you have posted warnings, not errors.
But warning can be big potential error.
For example in low optimization setting a uninitialized local variable may not generate error, but as soon as you go for higher optimization it may give error in run time.
move up....
Vindhyachal_Takniki:
move up....
See reply #1
TheMemberFormerlyKnownAsAWOL:
See reply #1
Have you read/checked this? Or you want anything else?
Vindhyachal_Takniki:
1.Partial Image of error is in post #1 - Whoop-de-do
2. code is in an attachment to post #4
3. text of an error message which may or may not be identical to the one you are seeing is in post #6Have you read/checked this? Or you want anything else?
Fixed that for you
Here are my replies:
This is complete error, please note. Or definition of error in my view and your view are completely different.
Thanks for pointing out this grammar mistake, very helpful on technical forum. Many would have missed the entire point due to this grammar error. Thanks one again.
Why would I point to this post, if error was different. If you have checked the attachment code, you would have got the error, Just by looking at image in post 1 and text in post 6, it can checked. But you didnt checked and posted comment, cant understand why???
@TheMemberFormerlyKnownAsAWOL Thanks for your time though.
Anyone else who can help to solve this issue?
2)It's not a grammatical error, it's a factual error.
Attachments can be difficult or impossible to open for members on mobile devices.
But, you're the one wanting help - why not make it easier for others to help you?
It was already mentioned for both image and text, you didn't checked still.. Image is in post 1 and text is in post 6. Repeating again and again.
This you mentioned now, earlier you added one word only. why changing your point now?
Same question comes to my mind. Noobs dont read the post and try to answer again and again to act as experts. Do you know why?
Already all information was there , picture of error, text of error, code , optimization setting, version number I am using . What else information was needed to get help.
So, just to be clear, you'd rather have an argument, than make it easier for other people to help you, by putting all the information, clearly in one single-authored post?
Yes to be clear:
You tried to make some comment without reading the thread. You are not able to accept it and pointing fingures now
picture of error, text of error, code , optimization setting, version number I am using , if this info is not enough for you then please better not reply and let other see if they can help.
Like post#6 person did, it pointed out under what optimization setting error comes, but you didn't read any of it, and posting without reading still
Have a nice day and let others help in case they can find something like post#6 does
One of the points you are perhaps missing is that many people read the forums on a tablet. So rather fewer of the folks that might be able to review your code can actually do so. If your thread is still on the first page next time I am using a real computer, I'll take a look.