CommunityGD32Cores / ArduinoCore-GD32

Arduino core for GD32 devices, community developed, based on original GigaDevice's core
Other
89 stars 33 forks source link

error: 'ltoa' was not declared in this scope; did you mean 'utoa'? #129

Open witsoft001 opened 4 months ago

witsoft001 commented 4 months ago

the test code is

void setup() { // put your setup code here, to run once: long num=12345; char s[20]; ltoa(num,s,10); }

the above code , when compile ,report below information:

D:\arduino-1.8.19\portable\sketchbook\sketch_may28a\sketch_may28a.ino: In function 'void setup()': sketch_may28a:7:1: error: 'ltoa' was not declared in this scope; did you mean 'utoa'? 7 | ltoa(num,s,10); | ^~~~ | utoa exit status 1 'ltoa' was not declared in this scope; did you mean 'utoa'?

the select board is GD32F3x0 Generic series, GD32F330C4, change to another type of GD32 is also this error. When I change the board to STM32 for arduino platform , the code is compile ok .

What's wrong with this problem?

thanks who can help me resolve this error.

maxgerhardt commented 4 months ago

Did you try to

#include <stdlib.h>

first?

The "Arduino way" would be to do

long num = 12345;
String asString = String(num);
const char* asCString = asString.c_str();