Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
witsoft001 opened this issue May 28, 2024 · 1 comment
Open
Assignees

Comments

@witsoft001
Copy link

witsoft001 commented May 28, 2024

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
Copy link
Member

maxgerhardt commented May 28, 2024

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants