Announcements

Join us FREE of charge at OktoberTech Asia Pacific and get inspired on how you could apply Digital Solutions for a smart Future. Click here to find out more.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Studio Bluetooth Forum Discussions

StN__1917156
Level 4
First like received First like given
Level 4

Is there any additional libraries or flags that have to put in the make file or whatever else needed to make this very basic C functionality to work?

I tried both

#include "stdio.h"

#include <stdio.h>

But always got:

D:\WICED-Studio-6.2\SDK\20719-B1_Bluetooth\WICED/../apps/w191/spp1/spp.c:517: undefined reference to `sprintf'

Tracking it back to declaration in stdio.h I've got:

int _EXFUN(sprintf, (char *__restrict, const char *__restrict, ...)

               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));

Thanks

P.S. Same story is and with stdlib.h and  malloc() and free():

D:\WICED-Studio-6.2\SDK\20719-B1_Bluetooth\WICED/../apps/w191/spp1/spp.c:520: undefined reference to `malloc'

D:\WICED-Studio-6.2\SDK\20719-B1_Bluetooth\WICED/../apps/w191/spp1/spp.c:521: undefined reference to `free'

0 Likes
1 Solution
SheetalJ
Moderator
Moderator 750 replies posted 500 likes received 500 replies posted
Moderator

Hi StN._1917156​,

The sprintf, malloc and free functions are not implemented in CYW20719B1 firmware.

However, instead of sprintf, you can use snprintf in following way:

char name[20];

int a=1;

snprintf(name, sizeof(name), "Try-%d", a);

WICED_BT_TRACE ("%s", name);

For malloc, free operations, you can use WICED APIs. Please refer wiced_memory.h for more details.

View solution in original post

0 Likes
1 Reply
SheetalJ
Moderator
Moderator 750 replies posted 500 likes received 500 replies posted
Moderator

Hi StN._1917156​,

The sprintf, malloc and free functions are not implemented in CYW20719B1 firmware.

However, instead of sprintf, you can use snprintf in following way:

char name[20];

int a=1;

snprintf(name, sizeof(name), "Try-%d", a);

WICED_BT_TRACE ("%s", name);

For malloc, free operations, you can use WICED APIs. Please refer wiced_memory.h for more details.

0 Likes