Does snprintf() exist for the ESP32? I see some references to it in esp-idf, but cannot actually seem to use it in code.
(If it just doesn't exist here, I'll work on including my own implementation.)
snprintf()
Re: snprintf()
A man page on what "snprintf" is can be found here...
https://linux.die.net/man/3/snprintf
Examining the header files for ESP-IDF, it would appear to be included in the distribution. What happens when you try and actually use it in code?
https://linux.die.net/man/3/snprintf
Examining the header files for ESP-IDF, it would appear to be included in the distribution. What happens when you try and actually use it in code?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 56
- Joined: Sun Dec 18, 2016 9:17 pm
Re: snprintf()
So it's weird... here's the error:
Turns out, if I #include <stdio.h> within the C code file itself, not just in the header file I'm already including, it works. That seems peculiar... if I have a header file with stdio.h in it, and include it, why won't it work? All the other includes work fine.
Code: Select all
error: implicit declaration of function 'snprintf' [-Werror=implicit-function-declaration]
note: include '<stdio.h>' or provide a declaration of 'snprintf'
Re: snprintf()
snprintf is included, as are most of the STDIO functions (if you find that something is missing, let us know...)
Source code comes from newlib: https://github.com/espressif/newlib-esp32
It's not included within the ESP-IDF repo for two reasons:
- compiling newlib as a component is fairly complex (if you want to achieve zero rebuild behavior on subsequent builds), and newlib build is fairly noisy.
- newlib happens to use certain functions which are embedded into the ESP32 ROM (parts of stdio have been placed into ROM to save space in applications). Therefore arbitrary modifications to newlib source code will not necessarily work (changing some newlib config values will not cause ROM parts of newlib to be updated...).
Newlib source code may be useful while debugging. If this is the case, you can clone the newlib repository mentioned above and add it to your gdb sources path.
Source code comes from newlib: https://github.com/espressif/newlib-esp32
It's not included within the ESP-IDF repo for two reasons:
- compiling newlib as a component is fairly complex (if you want to achieve zero rebuild behavior on subsequent builds), and newlib build is fairly noisy.
- newlib happens to use certain functions which are embedded into the ESP32 ROM (parts of stdio have been placed into ROM to save space in applications). Therefore arbitrary modifications to newlib source code will not necessarily work (changing some newlib config values will not cause ROM parts of newlib to be updated...).
Newlib source code may be useful while debugging. If this is the case, you can clone the newlib repository mentioned above and add it to your gdb sources path.
-
- Posts: 56
- Joined: Sun Dec 18, 2016 9:17 pm
Re: snprintf()
I figured out what I did wrong, and wouldn't have asked had I not edited the wrong file.
Once I straightened that out, I was good to go. Still, it's good to know more about newlib, so there's definitely that!
Best of all - I've released another version of the RGB LED driver! The original code had some serious timing issues that I've resolved - and I understand the RMT module a lot better now too.
https://github.com/MartyMacGyver/ESP32- ... ED-Drivers
Once I straightened that out, I was good to go. Still, it's good to know more about newlib, so there's definitely that!
Best of all - I've released another version of the RGB LED driver! The original code had some serious timing issues that I've resolved - and I understand the RMT module a lot better now too.
https://github.com/MartyMacGyver/ESP32- ... ED-Drivers
Who is online
Users browsing this forum: No registered users and 102 guests