arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.16k stars 7.02k forks source link

dtostrf is not available for ARM Cortex M4 (but should be by default) #9308

Closed dsyleixa closed 5 years ago

dsyleixa commented 5 years ago

dtostrf is not available for ARM Cortex M4. I'm using IDE 1.8.9, Arduino SAMD Boards M0+ 1.8.4 Adafruit SAMD Boards 1.5.4

D:\arduino\portable\sketchbook\libraries\MPU6050\MPU6050.cpp:3308:197: error: 'dtostrf' was not declared in this scope

how to fix that?

matthijskooijman commented 5 years ago

This function is not part of the Arduino API, nor of the standard C API AFAIK, I think it is just a AVR-libc addition that is just somewhat convenient and thus used. There should be alternatives to use (possibly functions that are not available on AVR, such as sprintf with float support). I think this issue has come up on this tracker (or maybe the arduinocore-sam repository) before, so maybe you could find some suggestions in an earlier issue: https://github.com/arduino/Arduino/issues?q=is%3Aissue+sort%3Aupdated-desc+dtostrf+is%3Aclosed

Also, please search for issues (including closed ones) before reporting a new one in the future. I'm closing this one as duplicate.

dsyleixa commented 5 years ago

yes, it seems to be in the standard AVR-libc which is installed by Arduino by default and thus available by default, and it's frquently and widely used by Arduino libs and sources. But as Arduino supports also other cores than AVR, this AVR-libc must be available also to all other cores by default.

dsyleixa commented 5 years ago

BTW, I have been searching for dtostrf ARM Cortex but didn't find resolved issues (still not yet, because as stated, it should be available by default for all cores just like for AVRs) - so it's NOT a duplicate actually.

per1234 commented 5 years ago

this AVR-libc must be available also to all other cores by default.

And it is. You just need to add this:

#include <avr/dtostrf.h>

to your program.

I have been searching for dtostrf ARM Cortex but didn't find resolved issues

I'm amazed by that, because when I click the link provided by matthijskooijman I find the answer in the very first result: https://github.com/arduino/Arduino/issues/3411

In the future, when you have an issue to report that is specific to the Arduino SAMD Boards core, please do it in the correct repository: https://github.com/arduino/ArduinoCore-samd (but search this issue tracker also first because there are many other people like you who don't use the correct issue tracker).

This issue tracker is only to be used for reporting issues related to the Arduino IDE or issues that don't match with any other official Arduino repository.

I have been searching for dtostrf ARM Cortex

You're poisoning your search by adding the completely unnecessary "ARM Cortex" keywords.

dsyleixa commented 5 years ago

You're poisoning your search by adding the completely unnecessary "ARM Cortex" keywords.

no, it's just what I am searching for: ARM Cortex!

per1234 commented 5 years ago

Those terms are almost never used in the Arduino world so you are indeed poisoning your search. You need to work on improve your search skills. It's an essential skill to have in this day and if you want to be a positive part of this issue tracker.

Locking this thread since it's no longer a productive discussion.