Error for use C function in OS 6 such as getc(), strcpy(), strtok()

Hi:
I am trying to update my program from Mbed OS2 to OS6, but face some problems in Serial communication with PC. I know OS6 use BufferedSerial(or UnbufferedSerial) instead of the Serial function in OS2, but some C fuction, such as getc(), strcpy(),strtok(), Error message shown:“Use of undeclared identifier 'strtok’clang(undeclared_var_use)”. Could youu please let me know hw to soult the problem? Thanks!
Dai

Sorry, some wrong words. send again.
I am trying to update my program from Mbed OS2 to OS6, but face some problems in Serial communication with PC. I know OS6 use BufferedSerial(or UnbufferedSerial) instead of the Serial function in OS2, but some C fuction, such as getc(), strcpy(),strtok(), Error message shown:“Use of undeclared identifier 'strtok’clang(undeclared_var_use)”. Could you please let me know how to solve the problem? Thanks!
Dai

Hi,

Did you use #include <string.h>?

That is unsolved bug for long time. Only possible solution is ignoring clang errors about STD functions.

BR, Jan

Thank reply!
Yes, I did . But error is still in there,

void command_split()
{
char *st;
int i = 0;
st=strtok(comdata, “,”);
while (st != NULL) {
s_data[i] = st;
st = strtok(NULL, “,”);
i++;
}
}

void command_receive()
{
index=0;
strcpy(comdata,mBuffer); //
memset(mBuffer, 0, sizeof(mBuffer)); //
command_split(); //

Thanks JohnnyK!
Do you know any other ideas could instead those functions?
Thanks lot for help!
Dai

I know about 2 solutions - ignoring the clang errors or make your own functions.
Usually when you try typing something like “strtok alternative” to google search, then you find somthing.

Implementing of strtok() function in C++ - GeeksforGeeks

BR, Jan

JohnnyK, Thanks lot! I will try it.
Dai

Hi MACRUM,
you remind me that " Did you use #include <string.h> ?,", Yes, I used #include <string.h> at begining in program, but error message is still shown "Use of undeclared identifier strcpy’clang(undeclared_var_use).
I checked the string.h and the strcpy function is included inside.
My question is, Do I also need add the string.h to use "ADD Mbed Library " Add an Mbed library to my project from os.mbed.com or add them from Git?
If yes, How to find the string.h or other C/C++ functions’ URL.
I am a beginner for Keil studio, and those errores give me many troubles.
Thanks lot for your or anyone to give me any supports,

Dai

No. The strtok() is C standard library function and the library is automatically linked to your project at link time.

Now, I just realized that the error you mentioned was in the Problems view of the Keil Studio Cloud.
This view is able to suggest problematic points in your code, but not always correct analysis (and this is not build error) . As Jan’s suggestion, you can simply ignore this error.

I personally never use this Problems view. :slight_smile:

Thanks,
Toyo

Hi Toyo,
Your answers are very useful for me. Right now my program can be compiled under Mbed OS2, but I try to update to OS6, and I have solved some problem but still some bugs in side.
Thanks lot.!
Dai