This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

strtok & strtok_r ERROR

I'm developing a small function that split string using delimiter (,) but i can't use strtok (undeclared function error)

so i added (CONFIG_NEWLIB_LIBC=y) to prj.conf file 

and now i can run the code with no error but when I'm trying to use the function (strtok or strtok_r) i got an error undefined behaviour from the system

(

08 NRF_SPIM3 Non-Secure OK
09 NRF_TIMER0 Non-Secure OK
10 NRF_TIMER1 Non-Secure OK
11 NRF_TIMER2 Non-Secure OK
12 NRF_SAADC Non-Secure OK
13 NRF_PWM0 Non-Secure OK
14 NRF_PWM1 Non-Secure OK
15 NRF_PWM2 Non-Secure OK
16 NRF_PWM3 Non-Secure OK
17 NRF_WDT Non-Secure OK
18 NRF_IPC Non-Secure OK
19 NRF_VMC Non-Secure OK
20 NRF_FPU Non-Secure OK
21 NRF_EGU1 Non-Secure OK
22 NRF_EGU2 Non-Secure OK
23 NRF_DPPIC Non-Secure OK
24 NRF_GPIOTE1 Non-Secure OK
25 NRF_REGULATORS Non-Secure OK

SPM: NS image at 0x18200
SPM: NS MSP at 0x20024c30
SPM: NS reset vector at 0x1a591
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.3.0-rc1-ncs2 ***

)

here's the function :

1) strtok_r

  char * token;

   while ((token= strtok_r(testBuffer, ',', &testBuffer)))
    printk("%s\n", token); 

2)strtok

char * token;

token= strtok(testBuffer, ',');
while (token != NULL)
{
token = strtok(NULL, ",");
}

any Suggestions?

Related